From patchwork Tue Oct 25 16:39:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 618138 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3523964pvb; Tue, 25 Oct 2022 09:56:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zKXqVx1J5w7Xhyw9LCvndRqF8WQzTErNbXVo6Q5QJIkMnnKCjdEPKy4q6JDf1vkfxWcBv X-Received: by 2002:a05:622a:54:b0:399:5b6c:654b with SMTP id y20-20020a05622a005400b003995b6c654bmr32993041qtw.362.1666716999913; Tue, 25 Oct 2022 09:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666716999; cv=none; d=google.com; s=arc-20160816; b=0smeQlXmM6rjgSWnM3T5cSKo+P8i7s2pFiGCsG+jw2Vlv/n/IlFt/2REZp3iuW1rWj MQZCgqqej4UujrTPxxL69ytAAD809t02LRf3C95sdk7Tp6OW3jYDSxeBqRMDqs/iI5M4 M2a+2gMt36FkKXII8A/DrkDAj1VUlvHhzvE+bhjiZzBDT4koRZGSeMSYAMedfHALrbCQ 0qW31RfIBTjEjmmhCzsj5UgK+JVnCjSMOw0VWZCjpbeqON2Ts+fdyv3hYF+lCV7RwQkk TvAjTGRWTjjd43su1lryOEtKcxwvtuzjiBMquumtZYiMhzFkgg3apkWHEr6rfUHiClcf Zl+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=DvesqOhV7EJhBL7AyS6aZECDQXhGGLTgIADuZfEnRis=; b=e6iYRKtQT73xiId8QJkan/B0VZusmBXfFhPPK8/RYBHuVLLwWIu5i3244hltHL0ETt 3n277hIiUHZLzY2/XuB78kyZ7irF5EKMECp6C+n1f9CoP7z/LyzAqBQGDxcpx5YmnpMQ G8/LegnMZZW8RDqH9h1EPQbEBdjieM3bLGM8Qp5NXTNghUYQarut70k1U2H3jmyqQdQZ 6jerb5whvjYUwoyLuBDU9DBriiGYSY34Q8J0hKMqDw5mezOQ6fzzw0F/66ijUWo2kJtP PLYz1M2C2Kf6YokfJjQuqrPt7tQJnLS4ZBLGvm0AhKj5d6OWE9yx6d9hd2dN8L5hGw3B 0hqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JtTBS6th; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h3-20020a37de03000000b006eec079ea91si1888573qkj.98.2022.10.25.09.56.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Oct 2022 09:56:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JtTBS6th; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzd-0007Kb-Bf; Tue, 25 Oct 2022 12:41:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onMz1-0006ef-CF for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:55 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyf-0001QL-IF for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:48 -0400 Received: by mail-wr1-x436.google.com with SMTP id o4so13850548wrq.6 for ; Tue, 25 Oct 2022 09:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DvesqOhV7EJhBL7AyS6aZECDQXhGGLTgIADuZfEnRis=; b=JtTBS6thioQuQ3+A8ybCW4frrq7RbRjQoX2uD8QRvB75FCmrh0td18e2j98l96+JbU JGWK9JZ9o7Mz7IXVG8gIj/th3cS0VLAhnMKHr5theWW94g6a8vMESl45oX/6Ebl38M98 /CLg74zoRiEmlca8mrdivrR6tU33Z3oR59wdvK09tyFV1b6dgEtPPF5pubvuT3x0V3O4 XwS6tT/UOzo8d40PABVbjNIFwBIVuE68p+R1g7bvLdXvf8PW0/FS5PMcQtAbPc5tmOMn 1Gv6M7pYWLe93LPVInRNGQQ/8gTOVkfPTDJsG+eJypbXa0CaF5aEDnGIFnPFs+UCdXnN mZBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DvesqOhV7EJhBL7AyS6aZECDQXhGGLTgIADuZfEnRis=; b=kK87JED6ZYsvOMfW30UyhZ1szUSJJ2x3CfLFDHecft8hdX9FuMV74B3+mhRU1D0Ll0 rHNwtjb8WZragBGKF5Jq4Vstw9yYrtYH8H2R3azXyYW0jHKDLA03n8z8G65DbzsmtBOU y3V05zoM0MP3WTE7biyltTM92jGYaG5jYZBOKeDpkXqG3Zl98S1w/zjVYIP8mg0QRKNw FLiY+CDim56gMA/nfDNbqNndCi5EIRHBDbq3z0ErluQyCJwfFQWhitqVTizr33ske4S1 pCKXg2eF8W7l4rHAN4gu3AyV+AWZ0bXqYI+1qqui9amQbC14T8SWqaBpglDqKLO3YjVF pUUA== X-Gm-Message-State: ACrzQf2tAvwxsg4BrTKvw01ZjV13jM3g1vXrxzstIh5gV7EXYeowj0fa r2t/uhFirFoBbOTgYG1m/MBj6ZWiDqPHPQ== X-Received: by 2002:a05:6000:1689:b0:22e:2c03:36e7 with SMTP id y9-20020a056000168900b0022e2c0336e7mr27347756wrd.252.1666716023758; Tue, 25 Oct 2022 09:40:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z12-20020a05600c220c00b003cd9c26a0basm2971084wml.40.2022.10.25.09.40.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:23 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/30] riscv: re-randomize rng-seed on reboot Date: Tue, 25 Oct 2022 17:39:47 +0100 Message-Id: <20221025163952.4131046-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221025163952.4131046-1-peter.maydell@linaro.org> References: <20221025163952.4131046-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: "Jason A. Donenfeld" When the system reboots, the rng-seed that the FDT has should be re-randomized, so that the new boot gets a new seed. Since the FDT is in the ROM region at this point, we add a hook right after the ROM has been added, so that we have a pointer to that copy of the FDT. Cc: Palmer Dabbelt Cc: Alistair Francis Cc: Bin Meng Cc: qemu-riscv@nongnu.org Signed-off-by: Jason A. Donenfeld Reviewed-by: Alistair Francis Message-id: 20221025004327.568476-6-Jason@zx2c4.com Signed-off-by: Peter Maydell --- hw/riscv/boot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index e82bf273388..ebd351c840d 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -30,6 +30,7 @@ #include "sysemu/device_tree.h" #include "sysemu/qtest.h" #include "sysemu/kvm.h" +#include "sysemu/reset.h" #include @@ -241,6 +242,8 @@ uint64_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt) rom_add_blob_fixed_as("fdt", fdt, fdtsize, fdt_addr, &address_space_memory); + qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds, + rom_ptr_for_as(&address_space_memory, fdt_addr, fdtsize)); return fdt_addr; }