From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716209; cv=none; d=zohomail.com; s=zohoarc; b=M/f9DRtOHxH7LS1Q8PdMLlmq/nq6YH/4Thuk3KplsjVr8WC7s4igTaC0IJq4iL0DxA1pvQFiJSCmHU9XHmzWXC8gDWBO000tTdId5XatHkleYUmWtCmBdryB6Kfb8YRXq2ze6KkxQcPbHgsORujzNXN382Cc+BHMnXMTPCH0edc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716209; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hY0POGqFqW7EijffbvLzF0Tmz3qfnjEYn1YZBVrMPJY=; b=NaIcByCpHBSLhlkky9tMyzx24BHh0MHwTN7w2GSqLlN6zIrS+r0g15eTFs/1BDNuanUNW3KgeTCW+11eVSnObXBA6cZ+6YKhL3fIX7nU9S/IdhP1zkJx3KW7hWG/kBWpqcBlBO/Gfy8I7aWVxRuitUcLP4p3/PPuzb7eF8z1BUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716209639310.26398535407225; Tue, 25 Oct 2022 09:43:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyB-00052Q-0h; Tue, 25 Oct 2022 12:40:03 -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 1onMy9-0004zr-24 for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:02 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMy6-0001OR-Pg for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:00 -0400 Received: by mail-wr1-x431.google.com with SMTP id z14so8564697wrn.7 for ; Tue, 25 Oct 2022 09:39:57 -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.39.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:39:55 -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=hY0POGqFqW7EijffbvLzF0Tmz3qfnjEYn1YZBVrMPJY=; b=lmY/TYV+Oquski4hdEXG79Ux52L2UHVXlPMIPix2t8mbt6UR3r/6iX9kHa2WSvvv8G +UJyk4zQl0Nni58BH5HVYlVhPyhsRJFGGBv8/C69wJStUk5e1vmnY94HyxK4Q3qbcOVF hsMDyCK7Xv7SrRI+hpyEu/6mXgXQkeEaaUG0CJcbctGElsw5bkt7e2QduU1Jcdh/8O8C +mTMfSwnPJ/frREB1VFr8YYvG5qoVmdgfkIpkfxQjDKkO0GvuM5aPLupnQdNneKnEEMJ OThTSyQpOY2P7Tk+JWR4iHVvXWx0QQZXyq79mZxdBhOjqtL7tDLnExpZql3yQ+4SkDXx /Wlw== 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=hY0POGqFqW7EijffbvLzF0Tmz3qfnjEYn1YZBVrMPJY=; b=o4tpoY4+fPUZC3kWEeldYApPEbtRNmGzUwMBQfrgJTam10iNdAIP3Nmqgo7xAj1QqG j5+DK1Z0TOggqUA9nsB2h12S/I3mluUaGmCRz62WDDyZjRd/8SV+TDLIDCjALnRu85sS RJApAvC+R+LKubWACjK+ONKo1YsHdadIZoRH6sBaIMdJYkSEEz5LuqZE6SwCLuiswuSL xn/yzAAmLUlxSIOV9b3reIh7snH1RcQYn9TGe6Z44midZ3Zv+1eiqQJ1dUNvTr/IS8YN mxh6wrocVOkV0mUekU9w9GCrOup3j2s4YGHfvDCoimGcEAvQChjIY8qISsvlNyEy5/Uf lvzQ== X-Gm-Message-State: ACrzQf1YvhokkWMaPodyAOhQ/iWvp6Yar4Ui+TnZKd2GtapuZSYvpMEt gmbFkvXvSZ5X6xtMhdHAdhRD5X4EhY1kkg== X-Google-Smtp-Source: AMsMyM4COY2qkaxTuhQEvx7mxvDHJxNSU3x9+cchOXNapPMEow2r3ao/xJWYHKRZb99vPjY0vZ8Gfg== X-Received: by 2002:adf:d1ca:0:b0:236:737f:8dfa with SMTP id b10-20020adfd1ca000000b00236737f8dfamr7228369wrd.588.1666715996190; Tue, 25 Oct 2022 09:39:56 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/30] target/arm: Implement FEAT_E0PD Date: Tue, 25 Oct 2022 17:39:23 +0100 Message-Id: <20221025163952.4131046-2-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716211496100003 Content-Type: text/plain; charset="utf-8" FEAT_E0PD adds new bits E0PD0 and E0PD1 to TCR_EL1, which allow the OS to forbid EL0 access to half of the address space. Since this is an EL0-specific variation on the existing TCR_ELx.{EPD0,EPD1}, we can implement it entirely in aa64_va_parameters(). This requires moving the existing regime_is_user() to internals.h so that the code in helper.c can get at it. Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-id: 20221021160131.3531787-1-peter.maydell@linaro.org --- docs/system/arm/emulation.rst | 1 + target/arm/cpu.h | 5 +++++ target/arm/internals.h | 19 +++++++++++++++++++ target/arm/cpu64.c | 1 + target/arm/helper.c | 9 +++++++++ target/arm/ptw.c | 19 ------------------- 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index cfb4b0768b0..fd61360a086 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -24,6 +24,7 @@ the following architecture extensions: - FEAT_Debugv8p4 (Debug changes for v8.4) - FEAT_DotProd (Advanced SIMD dot product instructions) - FEAT_DoubleFault (Double Fault Extension) +- FEAT_E0PD (Preventing EL0 access to halves of address maps) - FEAT_ETS (Enhanced Translation Synchronization) - FEAT_FCMA (Floating-point complex number instructions) - FEAT_FHM (Floating-point half-precision multiplication instructions) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 64fc03214c1..f8c59858063 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -4139,6 +4139,11 @@ static inline bool isar_feature_aa64_lva(const ARMIS= ARegisters *id) return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, VARANGE) !=3D 0; } =20 +static inline bool isar_feature_aa64_e0pd(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, E0PD) !=3D 0; +} + static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) !=3D 0; diff --git a/target/arm/internals.h b/target/arm/internals.h index c3c3920ded2..c8c5ca7b934 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -707,6 +707,25 @@ static inline uint32_t regime_el(CPUARMState *env, ARM= MMUIdx mmu_idx) } } =20 +static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) +{ + switch (mmu_idx) { + case ARMMMUIdx_E20_0: + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_MUser: + case ARMMMUIdx_MSUser: + case ARMMMUIdx_MUserNegPri: + case ARMMMUIdx_MSUserNegPri: + return true; + default: + return false; + case ARMMMUIdx_E10_0: + case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: + g_assert_not_reached(); + } +} + /* Return the SCTLR value which controls this address translation regime */ static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx) { diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 85e0d1daf1c..da95eabab5e 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1185,6 +1185,7 @@ static void aarch64_max_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64MMFR2, FWB, 1); /* FEAT_S2FWB */ t =3D FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ t =3D FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2= */ + t =3D FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */ cpu->isar.id_aa64mmfr2 =3D t; =20 t =3D cpu->isar.id_aa64zfr0; diff --git a/target/arm/helper.c b/target/arm/helper.c index c672903f432..252651a8d19 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10491,6 +10491,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, ps =3D extract32(tcr, 16, 3); ds =3D extract64(tcr, 32, 1); } else { + bool e0pd; + /* * Bit 55 is always between the two regions, and is canonical for * determining if address tagging is enabled. @@ -10502,15 +10504,22 @@ ARMVAParameters aa64_va_parameters(CPUARMState *e= nv, uint64_t va, epd =3D extract32(tcr, 7, 1); sh =3D extract32(tcr, 12, 2); hpd =3D extract64(tcr, 41, 1); + e0pd =3D extract64(tcr, 55, 1); } else { tsz =3D extract32(tcr, 16, 6); gran =3D tg1_to_gran_size(extract32(tcr, 30, 2)); epd =3D extract32(tcr, 23, 1); sh =3D extract32(tcr, 28, 2); hpd =3D extract64(tcr, 42, 1); + e0pd =3D extract64(tcr, 56, 1); } ps =3D extract64(tcr, 32, 3); ds =3D extract64(tcr, 59, 1); + + if (e0pd && cpu_isar_feature(aa64_e0pd, cpu) && + regime_is_user(env, mmu_idx)) { + epd =3D true; + } } =20 gran =3D sanitize_gran_size(cpu, gran, stage2); diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 6c5ed56a101..aed6f92d6f6 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -104,25 +104,6 @@ static bool regime_translation_big_endian(CPUARMState = *env, ARMMMUIdx mmu_idx) return (regime_sctlr(env, mmu_idx) & SCTLR_EE) !=3D 0; } =20 -static bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - switch (mmu_idx) { - case ARMMMUIdx_E20_0: - case ARMMMUIdx_Stage1_E0: - case ARMMMUIdx_MUser: - case ARMMMUIdx_MSUser: - case ARMMMUIdx_MUserNegPri: - case ARMMMUIdx_MSUserNegPri: - return true; - default: - return false; - case ARMMMUIdx_E10_0: - case ARMMMUIdx_E10_1: - case ARMMMUIdx_E10_1_PAN: - g_assert_not_reached(); - } -} - /* Return the TTBR associated with this translation regime */ static uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) { --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716544; cv=none; d=zohomail.com; s=zohoarc; b=USjN64KzDF7x5JxcbvdqO7VBzc+v7S0huVOY+ZEc4qLVvBXSWIQ/vOwvK18Evl8MDk1gQ3pf4/fItPJkZRF79UBuCDdiUH7m1ZWUWqfv9J6taJEVgvPtfllovbrhmPbKLCU0JnIvrWL+p5rWGpAl3nNjBSaFDvO1tyPJ23L5fgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716544; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=utmGtkV3MP5DXSAZKoAvE/klwIkMKDQpq8pKnbZX+nE=; b=ire7l8TBRnIOjjb26FqsoFiL7yIM/tNsG6tbcx91Z+HcHbwALLkbhlkE9xr3pxnoRVWislVhoX31ltYxEStWHwF15Zc/c7/NooegNBuSmDE27VS7N51lljVqoS7BdYq2tTASkSi+Bjh0Pert/RsnRPgv6OBITdQLUtGlyb1j5xI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716544323567.3646059089014; Tue, 25 Oct 2022 09:49:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyG-0005La-Qf; Tue, 25 Oct 2022 12:40:08 -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 1onMyE-00057c-0q for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:06 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMy6-0001OT-Pz for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:05 -0400 Received: by mail-wm1-x32c.google.com with SMTP id bh7-20020a05600c3d0700b003c6fb3b2052so8679904wmb.2 for ; Tue, 25 Oct 2022 09:39:58 -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.39.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:39:56 -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=utmGtkV3MP5DXSAZKoAvE/klwIkMKDQpq8pKnbZX+nE=; b=XcW1UDKPRnvCBmc7Mk5XxmBOXNMjn744zGtLPL/6j4EBwPy7XAfb11ouBsWDJuzc6r R4m1bfVjwWG6wZGt0lD/nrWbXR6FpiRn0eXgloFrzdH3zC8siR4mXUqQfowL+7tkh9ir r76QkEjVQQDuuG8k1e8wLKUqjaaJmMnXlyUWjQvmP0juIFTaasBeWEs6XrVnDXqrxJYm x2UvbXVeRzaR3VEdX7dYgUP0Jkvqy415is2dv4xe4XtX4ZjbDp6se5uAan0g0tkOY9wU r5o2+V0IFsrfJcMVVlBzio3f5GOfFZUmQbOAMgw5CxkhOff98nw95RdlSV979oxKivOM 5QTg== 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=utmGtkV3MP5DXSAZKoAvE/klwIkMKDQpq8pKnbZX+nE=; b=GXtoVePMh0qMX51axMa06rWoJ/EYSJGWPjK+HUL0bpO5Af6l1IaNrr6BTn+3fIaIS6 fDVOF1w5JMkAnoHUIGZ4+1uREt/T+olGg1A4dS+i1H9dAUm/1FXoEpGHHd9b3JckMvWW I055cED+9pcgoQnKSLB+Bi4dh2IcvJCiqfvbO20dT73M8HlZNHg2woGhrmUdA8RJjVF9 458hDVs/U/IC2+VZBXHebVVv3DrUHmkQ2xqlYqTWPLw/YrdOOGck8y/OxtId7Tkx/+BC SGVGOyGEEJrF1yxC/eHAe2NseibTwhn+z8ji3RhylOSoYRLfO1ZHN9nnVyjdG8G4s3tz lMxg== X-Gm-Message-State: ACrzQf0H+M8iJXs3xQI/12bAWNOaru6Rur8o4H35EmrWv4SBiW0K8jOt 3jx6m2BJ78S2enxzsFnU8Q8sJ4ZexVOXFg== X-Google-Smtp-Source: AMsMyM7FryKkY5UpnspV2IsIf38vG80h3QmNfDJKPExs/z6obzBnz5uiaMMNGBHVcSODTiYdekzNcw== X-Received: by 2002:a05:600c:3384:b0:3c6:f25a:96e9 with SMTP id o4-20020a05600c338400b003c6f25a96e9mr34935482wmp.112.1666715997213; Tue, 25 Oct 2022 09:39:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/30] hw/arm/virt: Fix devicetree warnings about the virtio-iommu node Date: Tue, 25 Oct 2022 17:39:24 +0100 Message-Id: <20221025163952.4131046-3-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716546203100003 Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker The "PCI Bus Binding to: IEEE Std 1275-1994" defines the compatible string for a PCIe bus or endpoint as "pci," or similar. Since the initial binding for PCI virtio-iommu didn't follow this rule, it was modified to accept both strings and ensure backward compatibility. Also, the unit-name for the node should be "device,function". Fix corresponding dt-validate and dtc warnings: pcie@10000000: virtio_iommu@16:compatible: ['virtio,pci-iommu'] does not = contain items matching the given schema pcie@10000000: Unevaluated properties are not allowed (... 'virtio_iommu@= 16' were unexpected) From schema: linux/Documentation/devicetree/bindings/pci/host-generic-pci= .yaml virtio_iommu@16: compatible: 'oneOf' conditional failed, one must be fixe= d: ['virtio,pci-iommu'] is too short 'pci1af4,1057' was expected From schema: dtschema/schemas/pci/pci-bus.yaml Warning (pci_device_reg): /pcie@10000000/virtio_iommu@16: PCI unit addres= s format error, expected "2,0" Signed-off-by: Jean-Philippe Brucker Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/virt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index cda9defe8f0..b8713508561 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1371,14 +1371,15 @@ static void create_smmu(const VirtMachineState *vms, =20 static void create_virtio_iommu_dt_bindings(VirtMachineState *vms) { - const char compat[] =3D "virtio,pci-iommu"; + const char compat[] =3D "virtio,pci-iommu\0pci1af4,1057"; uint16_t bdf =3D vms->virtio_iommu_bdf; MachineState *ms =3D MACHINE(vms); char *node; =20 vms->iommu_phandle =3D qemu_fdt_alloc_phandle(ms->fdt); =20 - node =3D g_strdup_printf("%s/virtio_iommu@%d", vms->pciehb_nodename, b= df); + node =3D g_strdup_printf("%s/virtio_iommu@%x,%x", vms->pciehb_nodename, + PCI_SLOT(bdf), PCI_FUNC(bdf)); qemu_fdt_add_subnode(ms->fdt, node); qemu_fdt_setprop(ms->fdt, node, "compatible", compat, sizeof(compat)); qemu_fdt_setprop_sized_cells(ms->fdt, node, "reg", --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716130; cv=none; d=zohomail.com; s=zohoarc; b=dxIiwjpu5oZHH0VgBWOWFUKZbXHpMJ5jbegYCVBnHk6oL3MMYP0NR7foblLEhutaK2pGi8IH6oAwZAB1g5O8jhWB8CuaOzuFUFzmFXqzoHwYboxTtsv82It22TPGvMBo4dKOz9WlT8jTLxW1638x3NP4m86yzpbU6T+eTEoZg3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716130; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BkdsxeivDrs8B1ekF6DlyQ39i4YB9EYQepwnyoXzyuw=; b=B9fpMr0RxDiHRUFpwj12Yh9J8fQ540fwnDO8+xYp98FmBsSWFXvWzu4YJCPu+cYU0o/mbNHJlbUkH+y9BH8p7TYcvOUJddXHeRheDSb2Qf0MzTnR9a/rJBwvwdqFqEujV1mWIJgMjwwlEqfic8bUxMFlcpczPyCmC9hqUJv/WzM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716130376919.5573973680579; Tue, 25 Oct 2022 09:42:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyS-0005pO-SV; Tue, 25 Oct 2022 12:40:21 -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 1onMyN-0005St-3v for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:15 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMy7-0001OZ-SL for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:14 -0400 Received: by mail-wm1-x32f.google.com with SMTP id l16-20020a05600c4f1000b003c6c0d2a445so8664441wmq.4 for ; Tue, 25 Oct 2022 09:39:59 -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.39.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:39:57 -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=BkdsxeivDrs8B1ekF6DlyQ39i4YB9EYQepwnyoXzyuw=; b=jCUxJwlBRj9DLNOLPVPQlLd6FPKz0e6uAZo8ZfHPiZlu6YcDigTC3dDQM1xxo3KNys z3xd/74gxow04mgfxkX47vtuHJEPDynMgikw/adB4bDCbdnUaYMkuQhpvp8WOBRTpE9A aooA2jF7ugTZMRfUdQlHXlkGyzbVs0LZmAxfpz8ougRwLE8+zA8l1g89MOT3gIkOJf0H PMH0hSO6zM6H6Jhb4IZiTQeZo5pNvPuAcURF+c63RxrTSMFcaamvksHrMuVsStjK41yr N/aN+V5YDJX2ljqOS6UAubvrh7fKQVGblo1h7oLailDfUdmHfImJPRkKjAM5acDX4Zzi Yx7Q== 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=BkdsxeivDrs8B1ekF6DlyQ39i4YB9EYQepwnyoXzyuw=; b=huWbHxS8+bDSE7TUETQKww6vs0Q50RGtizeqV5rWZ7UWpCMcW0NGe1F0LVishNe+vg t7RI4uoV4bPxE1Zn2+LOj8rD4BgMZsiZ02IGYgBSfD9mCVkz1tXpqolRXcG5k/CtNB+k akcXVfZs38tr+Y7bKeoFEu8vNWckBw55GV4o7GVl1oAw4vnQ2+qm3r2ReILAN+tFwoeP QMoYNIBpKoIXmAD2agWROtVtJVl5NxGy/bL4ardPEIoI2DV8lobWz0CLhloUdUDC9xAJ Za5cP4KH8k1H6PcK0YUgQruT0ZesjNoMeiHwmjPEiMCfesvCS4NU/5yvwepCky167itp Qe8g== X-Gm-Message-State: ACrzQf0acCfINJF787hv00erxkZKSEWdhweHusjmur1XSZGdY8BX2Xp/ /OEKsYv5Oy8y8wNcnetKGGk3uSStXpc/aA== X-Google-Smtp-Source: AMsMyM7eAYm3e3pcxvJD0PLhOq6Fe5brlGpUoVqJAdCHiQhUCeemwnDnrVouYZMQHHcwL6CopkrVZA== X-Received: by 2002:a05:600c:3509:b0:3c6:fd36:ef19 with SMTP id h9-20020a05600c350900b003c6fd36ef19mr27261282wmq.191.1666715998429; Tue, 25 Oct 2022 09:39:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/30] target/arm: honor HCR_E2H and HCR_TGE in arm_excp_unmasked() Date: Tue, 25 Oct 2022 17:39:25 +0100 Message-Id: <20221025163952.4131046-4-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716131162100001 Content-Type: text/plain; charset="utf-8" From: Ake Koomsin An exception targeting EL2 from lower EL is actually maskable when HCR_E2H and HCR_TGE are both set. This applies to both secure and non-secure Security state. We can remove the conditions that try to suppress masking of interrupts when we are Secure and the exception targets EL2 and Secure EL2 is disabled. This is OK because in that situation arm_phys_excp_target_el() will never return 2 as the target EL. The 'not if secure' check in this function was originally written before arm_hcr_el2_eff(), and back then the target EL returned by arm_phys_excp_target_el() could be 2 even if we were in Secure EL0/EL1; but it is no longer needed. Signed-off-by: Ake Koomsin Message-id: 20221017092432.546881-1-ake@igel.co.jp [PMM: Add commit message paragraph explaining why it's OK to remove the checks on secure and SCR_EEL2] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/cpu.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 0bc5e9b125b..8aa8a1419df 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -562,14 +562,24 @@ static inline bool arm_excp_unmasked(CPUState *cs, un= signed int excp_idx, if ((target_el > cur_el) && (target_el !=3D 1)) { /* Exceptions targeting a higher EL may not be maskable */ if (arm_feature(env, ARM_FEATURE_AARCH64)) { - /* - * 64-bit masking rules are simple: exceptions to EL3 - * can't be masked, and exceptions to EL2 can only be - * masked from Secure state. The HCR and SCR settings - * don't affect the masking logic, only the interrupt routing. - */ - if (target_el =3D=3D 3 || !secure || (env->cp15.scr_el3 & SCR_= EEL2)) { + switch (target_el) { + case 2: + /* + * According to ARM DDI 0487H.a, an interrupt can be masked + * when HCR_E2H and HCR_TGE are both set regardless of the + * current Security state. Note that we need to revisit th= is + * part again once we need to support NMI. + */ + if ((hcr_el2 & (HCR_E2H | HCR_TGE)) !=3D (HCR_E2H | HCR_TG= E)) { + unmasked =3D true; + } + break; + case 3: + /* Interrupt cannot be masked when the target EL is 3 */ unmasked =3D true; + break; + default: + g_assert_not_reached(); } } else { /* --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716750; cv=none; d=zohomail.com; s=zohoarc; b=KAZXHyKQ0IcXxbDAZ0GoZt8EPHC8OWeLocWfyuUQZzHt9g/Recs7G/Xe5I2k6x3i3+GeqOYiV1AiBdliAPQ8rOFQz+P8IYXgVjJ/EP1JykvYifuy4LGFtgv+hjHJmmmtHA74BoGsn7SB8t0uIcayQuyNR/bkcH9zstI0ul5roHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716750; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2ZLMGmvdBh5UWAIoQyzMmECFb98GcnB/juq4BvMu3x4=; b=mzJvdSUzp3l4MTgu2tBmE67gmZYBzyddjJHaoHzJlr+pHtefPW0g3zXiWuEXr1NNQBFSYvaDX2jQn4yjDSYJ5I6GS34n7sKzJHMmOg4G+oI2mhJYSOofVVtps/3PsKGKHwYyy1/GvElUN4WgkH6IBVRb63+ESOCnxZHCNSs+7F0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716750194825.5998451248919; Tue, 25 Oct 2022 09:52:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyQ-0005if-Jv; Tue, 25 Oct 2022 12:40:18 -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 1onMyI-0005Oe-AQ for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:13 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyA-0001Od-HD for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:10 -0400 Received: by mail-wm1-x32a.google.com with SMTP id l32so8489501wms.2 for ; Tue, 25 Oct 2022 09:40:00 -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.39.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:39:58 -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=2ZLMGmvdBh5UWAIoQyzMmECFb98GcnB/juq4BvMu3x4=; b=OE8gAHnuWmScYcgLtsW5t1HAlN0BuIM+rd1R5fnSZgsivUL8TbgPhzUc+y91JWG0Lz NFSn1hvEARGX57Jrawq/VBh4G4qILWL4eKOcquKeLRv2yU0rX7bD5gsqYl2MoVUs9Pli +TPa5vJSL+v9PJH4rFvxCf48ECKop0hUh2dpOUSvQPIN+Y4zcr+W7lf0oE4OivBRJ6uo GF1hsbN4ffGBV9kKibWzXJChpk0SgbYXDE2T3dInNw+QDL30EvmnMnsMQ0iFAROjg7In QCovxmim006iaNtHvY3A0XGh/aQ+fb6+iLUF1uh88u+uiUM5et6LGx3S0oAxqt6zbSfo IQaw== 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=2ZLMGmvdBh5UWAIoQyzMmECFb98GcnB/juq4BvMu3x4=; b=7yqMgBcTy3qgGflbwrAGqXYJKvKilEBNQbKRomu/lzLFMKu1hjVdvBuMm5c6H785Fr LGzmzdTGm143Du9vSLOt6n0yXZrZB4hAbGWcmorpBfrAnPWRcnOsM6VdBYnsK8mKjmIw rpYJ4pZm4ojjcnI+L8Yau/wzMPLUei9wsHbO7NzIUqf+x+pQFvtS7SiwJ7gPxEyfJT3r wIMvAYRafJUTjH/DZQcdde7eBFu4cTro0Nwp1QBNksmNnC8L1rGOiKQIB9bJNZIMWx96 3QObXYRQ2T2VvMyKwP2L1KRPxc7za/iMmKAvlvJplfraH/64V0Dq8hg2ZoAUckRqz+Eh PjpQ== X-Gm-Message-State: ACrzQf02qUxbkccEgn+TcvBvqVY5lbdYKdRFH4j/KtkICrFAovgOUBKY SdBazPA+1iUVAQQ7lyp2WzzWtWnF/SNsEQ== X-Google-Smtp-Source: AMsMyM4zgke6ALTnK3bP6TTubD5Aqx6ECEuRxYcjeBlnEjJFWPVsctaKi5w9ZSHiQo0VB0r1GJtw3A== X-Received: by 2002:a05:600c:230d:b0:3c4:2975:321a with SMTP id 13-20020a05600c230d00b003c42975321amr47466204wmo.155.1666715999460; Tue, 25 Oct 2022 09:39:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/30] hw/core/resettable: fix reset level counting Date: Tue, 25 Oct 2022 17:39:26 +0100 Message-Id: <20221025163952.4131046-5-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716751201100007 From: Damien Hedde The code for handling the reset level count in the Resettable code has two issues: The reset count is only decremented for the 1->0 case. This means that if there's ever a nested reset that takes the count to 2 then it will never again be decremented. Eventually the count will exceed the '50' limit in resettable_phase_enter() and QEMU will trip over the assertion failure. The repro case in issue 1266 is an example of this that happens now the SCSI subsystem uses three-phase reset. Secondly, the count is decremented only after the exit phase handler is called. Moving the reset count decrement from "just after" to "just before" calling the exit phase handler allows resettable_is_in_reset() to return false during the handler execution. This simplifies reset handling in resettable devices. Typically, a function that updates the device state will just need to read the current reset state and not anymore treat the "in a reset-exit transition" as a special case. Note that the semantics change to the *_is_in_reset() functions will have no effect on the current codebase, because only two devices (hw/char/cadence_uart.c and hw/misc/zynq_sclr.c) currently call those functions, and in neither case do they do it from the device's exit phase methed. Fixes: 4a5fc890 ("scsi: Use device_cold_reset() and bus_cold_reset()") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1266 Signed-off-by: Damien Hedde Signed-off-by: Peter Maydell Reported-by: Michael Peter Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20221020142749.3357951-1-peter.maydell@linaro.org Buglink: https://bugs.launchpad.net/qemu/+bug/1905297 Reported-by: Michael Peter [PMM: adjust the docs paragraph changed to get the name of the 'enter' phase right and to clarify exactly when the count is adjusted; rewrite the commit message] Signed-off-by: Peter Maydell --- docs/devel/reset.rst | 8 +++++--- hw/core/resettable.c | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst index abea1102dc4..7cc6a6b3140 100644 --- a/docs/devel/reset.rst +++ b/docs/devel/reset.rst @@ -210,9 +210,11 @@ Polling the reset state Resettable interface provides the ``resettable_is_in_reset()`` function. This function returns true if the object parameter is currently under rese= t. =20 -An object is under reset from the beginning of the *init* phase to the end= of -the *exit* phase. During all three phases, the function will return that t= he -object is in reset. +An object is under reset from the beginning of the *enter* phase (before +either its children or its own enter method is called) to the *exit* +phase. During *enter* and *hold* phase only, the function will return that= the +object is in reset. The state is changed after the *exit* is propagated to +its children and just before calling the object's own *exit* method. =20 This function may be used if the object behavior has to be adapted while in reset state. For example if a device has an irq input, diff --git a/hw/core/resettable.c b/hw/core/resettable.c index 96a99ce39ea..c3df75c6ba8 100644 --- a/hw/core/resettable.c +++ b/hw/core/resettable.c @@ -201,12 +201,11 @@ static void resettable_phase_exit(Object *obj, void *= opaque, ResetType type) resettable_child_foreach(rc, obj, resettable_phase_exit, NULL, type); =20 assert(s->count > 0); - if (s->count =3D=3D 1) { + if (--s->count =3D=3D 0) { trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.e= xit); if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) { rc->phases.exit(obj); } - s->count =3D 0; } s->exit_phase_in_progress =3D false; trace_resettable_phase_exit_end(obj, obj_typename, s->count); --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716057; cv=none; d=zohomail.com; s=zohoarc; b=A6A67HGbdWx9CbUntMXJFTFedMsp4RSoo65kxQsmMIP8wBBZztdgbqiugHfL/MKj+4Lv7xra6rO4AZVMrP8AOZyNAU/tjXZIcLf3MhIyJfIN1hFj9rqu/EC417UqpTjr2qiIxN7Lb832O8vLZbQuTtbpX9mw0hbl/u4orFsVwIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716057; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HQ5kM2p1/qrerMOx1us9zdpzRSiqNswYiSblD+T/iHk=; b=nbbnIzfMdS2RDr76XsSIvxh75X1TRETG+irH5r41Gp468/wk/cwN+cG+KX4OAsXPC1bQ479l8FCFIjsz11/QLyU5SpmF2rVuAOICGSNTHO0PTt9WvT2bZxukCWx3cp9asBVcTL8XAP4ZvcHfWls/dBjDmvRb21JwXT96lF4zI9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716057485926.2637844868952; Tue, 25 Oct 2022 09:40:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyF-0005FU-Tb; Tue, 25 Oct 2022 12:40:07 -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 1onMyD-00056N-CJ for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:05 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyA-0001Oi-PK for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:05 -0400 Received: by mail-wm1-x336.google.com with SMTP id bg9-20020a05600c3c8900b003bf249616b0so8672694wmb.3 for ; Tue, 25 Oct 2022 09:40:02 -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.39.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:39:59 -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=HQ5kM2p1/qrerMOx1us9zdpzRSiqNswYiSblD+T/iHk=; b=jd+1dMV2tjayVINIiiDqwAO0PuE23M56qrLO5VuEAW/oH41WTb4DpA+zcT2G73aaqw AMZQCtRhjB317b1QoWmMWvjCSienAW1sZ3yiuis7xq3Ot1xI8ncvATXDdZmJJbQ6lSId n5qsslOITNVpqpchSh91f+1Q7E1LVTms7Vh3CAOQ2XhZWg4YpgIKfm3At8fC4A9BSD1N iFwdnImJ5oR1iLbuJv5F8vgw+GVQCZD15q1MVrUNZRxRO+TQk448d01XIyo/RImhTOFf 9+ZI8a4rVbRWPeNKrmCDDZVwDKZreEL1gZf3RZeIfRIF/MXrLreE2Vqi0uDVK6aAyys/ 5E7Q== 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=HQ5kM2p1/qrerMOx1us9zdpzRSiqNswYiSblD+T/iHk=; b=NNEL2O+dxQxwYf0zWF5nGtBZDzWiQGQmkSmZIwiopSBD0EIY3sYUgyh/JEMxKY+Goc mFwlPCPh8z1D8tyIlF42P3iNKBi4CogGAOYe9LqLhDj3z0VMJ19ZibBzQwTERhj6JMYD H0LgUj1tOTl9ikOeUkOf1BHxzB3x1agZ6J4g/nqvwgdd2tuldJdi96ZUoIoGDkxDM/il 3C71zSDRCYHj3KLktV8R9c5eZ97KqcMqYvnkfj+gwh55yrOtrZxmU/LOzOAECnjYhdbG yBN3fGkX1hUm8ZhLAvvHdkycZoBOX29ZRToJcj1QkozPzbIEaSTiCdl7UBKe43hDsxG4 abRA== X-Gm-Message-State: ACrzQf1S5GUgCQCj5cQ0BxGzqm2oYzgusRt3DSmAM2FjiFGfNC6tD28/ YRE/8CIw98JefkSWm/71Ci8YslCJdx6XfQ== X-Google-Smtp-Source: AMsMyM5TEZZYYv6jg1oQRDi/w890l4E6bxk0SZpIRSA/kFIWee6GVMGX9hG9i8I517UpThOqvh/dZg== X-Received: by 2002:a05:600c:4f04:b0:3c6:fae5:b4d4 with SMTP id l4-20020a05600c4f0400b003c6fae5b4d4mr27082575wmq.103.1666716000431; Tue, 25 Oct 2022 09:40:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/30] hw/hyperv/hyperv.c: Use device_cold_reset() instead of device_legacy_reset() Date: Tue, 25 Oct 2022 17:39:27 +0100 Message-Id: <20221025163952.4131046-6-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716058715100003 Content-Type: text/plain; charset="utf-8" The semantic difference between the deprecated device_legacy_reset() function and the newer device_cold_reset() function is that the new function resets both the device itself and any qbuses it owns, whereas the legacy function resets just the device itself and nothing else. In hyperv_synic_reset() we reset a SynICState, which has no qbuses, so for this purpose the two functions behave identically and we can stop using the deprecated one. Signed-off-by: Peter Maydell Reviewed-by: Maciej S. Szmigiero Message-id: 20221013171817.1447562-1-peter.maydell@linaro.org --- hw/hyperv/hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index 4a1b59cb9db..57b402b9561 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -157,7 +157,7 @@ void hyperv_synic_reset(CPUState *cs) SynICState *synic =3D get_synic(cs); =20 if (synic) { - device_legacy_reset(DEVICE(synic)); + device_cold_reset(DEVICE(synic)); } } =20 --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716206; cv=none; d=zohomail.com; s=zohoarc; b=VfACXdjhgypZaipYE/pf7wU8AhzdNlyfb/DvzRwoDqFKQwqJDHX6KXurrA1jeTseGVsYlPA9rZcQShjJucq0IaVtJeljG1GPBG9Z79/QlALRNbLUagkx9eI1hAz64L1ork3LlZpqspLrEFEO+Zh0rBbCuxFUOynuoHgtfTCsicw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716206; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vyKoVIaZ14z5rmK2eOBlHnplzEcKxB4jMXPTjeFMRWo=; b=NRe3sG+USCw639/QfeMVZ50o6vC00rq38vrIm5ZE2FAmnu4g+Mv8YCgg3hMXhO0+g1+gZQUg6UfycchKWN+0jv70Y+u7ssM6l4yFY+dxYPAbfBw5LVWempLTHXv2zfyDTrb5IscxFS/5/4jUG5zXeDZf6QxabPzMucumTSXNHa8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716206220787.1800993426843; Tue, 25 Oct 2022 09:43:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyL-0005Pe-ID; Tue, 25 Oct 2022 12:40:13 -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 1onMyJ-0005Oi-KF for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:12 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyD-0001Q3-6U for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:11 -0400 Received: by mail-wr1-x42f.google.com with SMTP id h9so10986469wrt.0 for ; Tue, 25 Oct 2022 09:40:04 -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.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:00 -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=vyKoVIaZ14z5rmK2eOBlHnplzEcKxB4jMXPTjeFMRWo=; b=f7582MHa9Cux2cSBMZEregsz/Mwwj9fOVC3WM58/cOz6ZlaaWRGbqHO84l72g3kZrk 8cHz7WYPe39uyPQ/gm0KANcDbSd3AODjh+TXG8KpmdpiuujU6H1HQrr5mLV/x/UFl9wG Mtu5yq32tojIkHcQHrWPP4VZb07O7glS1FJgD3xb9YkQ3zxShGVEx3ruJ9ZWDYUs4v6e SdfzXMTHDE/I/lS4ozJYnEtqXwUzZqwV+SKQtHlH2bt/ZaoimQ16Uy2XdnT7V54/XKXH jcMKBvoX4QE4Ub1kaFDjRy4mR8pCNIzQBn7i3BLMCGJJkggZjMozvEva1cR8H/B8cSIJ 0vHg== 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=vyKoVIaZ14z5rmK2eOBlHnplzEcKxB4jMXPTjeFMRWo=; b=ooozL9lv7vtMGnDCDWg0Rp+EfHHtTYLSIWpGB8xZH4w6pew5QHhCS2hZYVDqfaFs+M tHsprxNUIl+niuqvWmc2laPrxdbJTVkcFI4dLY0I9HIBavxiPTZvva1EEArP/ycAg9ZV TW18buTQ00ACVwgGNdyIpCZttvESsgks2XTpRGZFEYgajVjF+WZvX4LuNSwZw3GniXyi PmW6f3af2eoC0EQw/fpNnZhJOkWfhv4F6+S0zhtL+A4jKus2Aa9SPsm6oEY74H7ZB3gN 5DwUqrFSPxfVyNHJRhnaKWDHI14/pth/ncYCNNCIihB6tFLAxaAbGCycgzqkofAEQ03M 9k6g== X-Gm-Message-State: ACrzQf3/uPwh/IzIYVroBkqnHIcfpoXYMU3kSa6mi2oOPOMhNDH15B7P NJg7S/NDjLQzboLDjlhystxuAN5ZySmPzQ== X-Google-Smtp-Source: AMsMyM48k7bEBwg6/Nt84s7fjHQ8uN7ljFbkBbY2pylHxLWFePuR4nfxqKFgTFEKPUZh12ZgIlg/9Q== X-Received: by 2002:a05:6000:15cf:b0:230:ba81:cefc with SMTP id y15-20020a05600015cf00b00230ba81cefcmr26121432wry.544.1666716001783; Tue, 25 Oct 2022 09:40:01 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/30] target/imx: reload cmp timer outside of the reload ptimer transaction Date: Tue, 25 Oct 2022 17:39:28 +0100 Message-Id: <20221025163952.4131046-7-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716207481100001 Content-Type: text/plain; charset="utf-8" From: Axel Heider When running seL4 tests (https://docs.sel4.systems/projects/sel4test) on the sabrelight platform, the timer tests fail. The arm/imx6 EPIT timer interrupt does not fire properly, instead of a e.g. second in can take up to a minute to finally see the interrupt. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1263 Signed-off-by: Axel Heider Message-id: 166663118138.13362.1229967229046092876-0@git.sr.ht Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/timer/imx_epit.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c index 2bf8c754b21..ec0fa440d72 100644 --- a/hw/timer/imx_epit.c +++ b/hw/timer/imx_epit.c @@ -275,10 +275,15 @@ static void imx_epit_write(void *opaque, hwaddr offse= t, uint64_t value, /* If IOVW bit is set then set the timer value */ ptimer_set_count(s->timer_reload, s->lr); } - + /* + * Commit the change to s->timer_reload, so it can propagate. Othe= rwise + * the timer interrupt may not fire properly. The commit must happ= en + * before calling imx_epit_reload_compare_timer(), which reads + * s->timer_reload internally again. + */ + ptimer_transaction_commit(s->timer_reload); imx_epit_reload_compare_timer(s); ptimer_transaction_commit(s->timer_cmp); - ptimer_transaction_commit(s->timer_reload); break; =20 case 3: /* CMP */ --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716386; cv=none; d=zohomail.com; s=zohoarc; b=I9GiY7TesYnrIvIZJ9FTroOmdbqxCN/uz+hll9uCU7c84wpkOWzkfsv0HgYM90mdz5sTvfjj7Wr6ejkpMSILS1UJXtTwFRgAZoH0uHlYHp/OSSU8jzqc++rgogxy6L5NllP7UEq3oe2dTGrERSJH5x8KW72yjuQsmcylWcJp62o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716386; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2fAexE0Wap1xOoTyj0oQWz/3m3axw41tbUCxvv4K5m4=; b=bPLWWNUWlkG120p9Hb3Y5rbTgmGX5baLYBrLSZLCqj21lVbxF7speTgf/FBp917go6+4vtDQxz+s3IipnFGAG/ABqbRNqY5kHvNqfNS6s3/Cyg+9iiuqdsjAJMn9d6CJzwnI7JxOcxeUbUxuQbesimkRBJdUIMxL1JWOyS2KQP8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716386184797.0493174106141; Tue, 25 Oct 2022 09:46:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMz4-0006k1-BM; Tue, 25 Oct 2022 12:40:58 -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 1onMyg-0006D4-4S for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:34 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyN-0001cV-Pf for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:25 -0400 Received: by mail-wr1-x42a.google.com with SMTP id y16so11623928wrt.12 for ; Tue, 25 Oct 2022 09:40:15 -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.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:02 -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=2fAexE0Wap1xOoTyj0oQWz/3m3axw41tbUCxvv4K5m4=; b=vWUPlOmZJosDoBa7oe1cHVoMGwnIQYtr+/5yy1rJnWCY1KDilvwLItHGIcMto92ECp WyX2md2tTb82sfFMBHxBNJC1x4BJca4okG74FwJKYSCRIOhm6lLjE0n+dnf2tVTHZsPg fsE//2FHHIWsu/orRbafjVAJCO11GeS2WyybwvzMffaGVyaSh9/nQsKwE4ucnyISliYF rthXFCayMj2Mi+qwbMRb2SGWTpaOm702JmyGFafDtsj/Qf+d0k0jRkK3fif8at3kVe9j IkdW4JsUqvTHUUCeL0c4N4ep5nbjc4l5ZOa+paqPxQ9LnOpXWqAYBKAYXa/GsGiUkWXW 462g== 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=2fAexE0Wap1xOoTyj0oQWz/3m3axw41tbUCxvv4K5m4=; b=PvEZ7qKE1FcK2AjcL6c0LILdcXwtMbPT5q0dHh4UdzrkyInLiv/GAwnqAMiYW5VnlO 8+Kgtugh85km0n3/zDx5RC77kI7pahDRvO1+ddinRFp0cG8PbTrVxW15+QO37SWSvzd6 1MQULSqnSdN5JTYYBvcjp6zB9rbvaPeqhE156t9mm+OGE8VDeXikGUvNBzlkgIR7m9q2 u2h94Ol+lKB2ZeT10qXq4iRj31aKVML6HecqnKHGKG+1G9D2/4mzhTe4kbk2+0WQubpZ DnRtcpMudTequ4dhtZBq0yBEs+wki8YzU3zZX81o1GJldGFH2bICsAzL/EEXgtR4fgPi gP1Q== X-Gm-Message-State: ACrzQf3fMoQ0MaZpSNr64dY5IjA1jeA4sLESVvKpsR7SmScddoyvL4XS rR6Q+7XfU3C8au9hNFt6aAWNlZfAu8alGQ== X-Google-Smtp-Source: AMsMyM6QONnDfi9uWCId4bC5H7UHuJaDuixwwRBQFF7D6sn/QbXLNci2iieFauCfoYySqjEbtHo/gg== X-Received: by 2002:a05:6000:1548:b0:22e:3469:b726 with SMTP id 8-20020a056000154800b0022e3469b726mr25787235wry.10.1666716003037; Tue, 25 Oct 2022 09:40:03 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/30] target/arm: Introduce regime_is_stage2 Date: Tue, 25 Oct 2022 17:39:29 +0100 Message-Id: <20221025163952.4131046-8-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716388358100003 From: Richard Henderson Reduce the amount of typing required for this check. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Message-id: 20221024051851.3074715-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 5 +++++ target/arm/helper.c | 14 +++++--------- target/arm/ptw.c | 14 ++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index c8c5ca7b934..abfb32d77c2 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -673,6 +673,11 @@ static inline bool regime_is_pan(CPUARMState *env, ARM= MMUIdx mmu_idx) } } =20 +static inline bool regime_is_stage2(ARMMMUIdx mmu_idx) +{ + return mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Sta= ge2_S; +} + /* Return the exception level which controls this address translation regi= me */ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) { diff --git a/target/arm/helper.c b/target/arm/helper.c index 252651a8d19..47afaec6b44 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10352,7 +10352,7 @@ int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx m= mu_idx) { if (regime_has_2_ranges(mmu_idx)) { return extract64(tcr, 37, 2); - } else if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx= _Stage2_S) { + } else if (regime_is_stage2(mmu_idx)) { return 0; /* VTCR_EL2 */ } else { /* Replicate the single TBI bit so we always have 2 bits. */ @@ -10364,7 +10364,7 @@ int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx = mmu_idx) { if (regime_has_2_ranges(mmu_idx)) { return extract64(tcr, 51, 2); - } else if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx= _Stage2_S) { + } else if (regime_is_stage2(mmu_idx)) { return 0; /* VTCR_EL2 */ } else { /* Replicate the single TBID bit so we always have 2 bits. */ @@ -10474,7 +10474,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, int select, tsz, tbi, max_tsz, min_tsz, ps, sh; ARMGranuleSize gran; ARMCPU *cpu =3D env_archcpu(env); - bool stage2 =3D mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMM= MUIdx_Stage2_S; + bool stage2 =3D regime_is_stage2(mmu_idx); =20 if (!regime_has_2_ranges(mmu_idx)) { select =3D 0; @@ -10541,22 +10541,18 @@ ARMVAParameters aa64_va_parameters(CPUARMState *e= nv, uint64_t va, } ds =3D false; } else if (ds) { - switch (mmu_idx) { - case ARMMMUIdx_Stage2: - case ARMMMUIdx_Stage2_S: + if (regime_is_stage2(mmu_idx)) { if (gran =3D=3D Gran16K) { ds =3D cpu_isar_feature(aa64_tgran16_2_lpa2, cpu); } else { ds =3D cpu_isar_feature(aa64_tgran4_2_lpa2, cpu); } - break; - default: + } else { if (gran =3D=3D Gran16K) { ds =3D cpu_isar_feature(aa64_tgran16_lpa2, cpu); } else { ds =3D cpu_isar_feature(aa64_tgran4_lpa2, cpu); } - break; } if (ds) { min_tsz =3D 12; diff --git a/target/arm/ptw.c b/target/arm/ptw.c index aed6f92d6f6..32d64125865 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -823,8 +823,7 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_i= dx, bool is_aa64, bool have_wxn; int wxn =3D 0; =20 - assert(mmu_idx !=3D ARMMMUIdx_Stage2); - assert(mmu_idx !=3D ARMMMUIdx_Stage2_S); + assert(!regime_is_stage2(mmu_idx)); =20 user_rw =3D simple_ap_to_rw_prot_is_user(ap, true); if (is_user) { @@ -1152,7 +1151,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, goto do_fault; } =20 - if (mmu_idx !=3D ARMMMUIdx_Stage2 && mmu_idx !=3D ARMMMUIdx_Stage2_S) { + if (!regime_is_stage2(mmu_idx)) { /* * The starting level depends on the virtual address size (which c= an * be up to 48 bits) and the translation granule size. It indicates @@ -1323,7 +1322,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, attrs =3D extract64(descriptor, 2, 10) | (extract64(descriptor, 52, 12) << 10); =20 - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_St= age2_S) { + if (regime_is_stage2(mmu_idx)) { /* Stage 2 table descriptors do not include any attribute fiel= ds */ break; } @@ -1355,7 +1354,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, =20 ap =3D extract32(attrs, 4, 2); =20 - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { + if (regime_is_stage2(mmu_idx)) { ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; xn =3D extract32(attrs, 11, 2); result->f.prot =3D get_S2prot(env, ap, xn, s1_is_el0); @@ -1385,7 +1384,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, result->f.guarded =3D guarded; } =20 - if (mmu_idx =3D=3D ARMMMUIdx_Stage2 || mmu_idx =3D=3D ARMMMUIdx_Stage2= _S) { + if (regime_is_stage2(mmu_idx)) { result->cacheattrs.is_s2_format =3D true; result->cacheattrs.attrs =3D extract32(attrs, 0, 4); } else { @@ -1416,8 +1415,7 @@ do_fault: fi->type =3D fault_type; fi->level =3D level; /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ - fi->stage2 =3D fi->s1ptw || (mmu_idx =3D=3D ARMMMUIdx_Stage2 || - mmu_idx =3D=3D ARMMMUIdx_Stage2_S); + fi->stage2 =3D fi->s1ptw || regime_is_stage2(mmu_idx); fi->s1ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; return true; } --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666717772; cv=none; d=zohomail.com; s=zohoarc; b=OdBc49CdDpmBmoMURYOuba8kFw1xQMRZ9MwUAbqG5LUepUzetAana7WNQ+h04HtQTkYkOeeJzCoRmc2Nv8q7u/O/vp1jd5Jiu2YAgjMBaDNZqbou4E97vcZ3MgFWiyzTrQzhRBYlWsgFEfIe5PHxhct3WC1DiTzE13Heayxo/ME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666717772; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P/80oQnk9crqK9/8NPPpJzCTwL4yLPZIVLR69kwqvuo=; b=Lb71LQyttjvhLubthZRCz2gPiCdP4vD/cbn86nviCf5akv/WInn94yzFzwyihQXw5iLZCXKQ5Xn+H4l4aiDTQgebAkvW9TJbCC9TEezUmSn7/XmjYPQSa2mW6jr9flwGd1LRTa52fKFT3lBlHjZsdlTAE199Ee7NWrZR2/WudN8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666717772196337.97231781379855; Tue, 25 Oct 2022 10:09:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyN-0005UR-FP; Tue, 25 Oct 2022 12:40:15 -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 1onMyI-0005Of-L9 for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:13 -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 1onMyE-0001QL-Qo for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:10 -0400 Received: by mail-wr1-x436.google.com with SMTP id o4so13848922wrq.6 for ; Tue, 25 Oct 2022 09:40:05 -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.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:03 -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=P/80oQnk9crqK9/8NPPpJzCTwL4yLPZIVLR69kwqvuo=; b=oadD6IkN6wKVacLi09l9erNes0UPHwjs5c3hqNI1ZZ1I+VJsb54Q3iCUtCHfam3BQ+ ek5wRfz5Q3oRYfPWLIENEoV2T5fOSF6BKzJ2k6wDUm+mFkcGruu2ONXA3EN7IXA03GDE 0BIEB1i4poIdL1anLwwXQ1v0kmqc/MXcsMrgRA50QjSwMscYi5S3luDrRBubdNR9sSWq cFi9GG9r8w+iDTufJTzM1pH5KYD3F0gK9lAfHWvZ7/Qj0ryYTRQsBiiRwiav1o9gf8Mx gv9iDJNHEVTrzbwn/y+/KehRDw7ePgrveUEl2BZyvOC6kbmRVtEgzl2uJG0Ha8bsOEhQ iEMw== 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=P/80oQnk9crqK9/8NPPpJzCTwL4yLPZIVLR69kwqvuo=; b=EXs38q3lqankgCfBbH+k16O/PSoX0tfDd6DMW9BlMIVVLkF8Qgl3RkbnsYX9mnf8xR SUifWPXDB2HZYfmxwKyEIwnObNnz2tXe77aDHcquTqxDKHdFCOeqiBeQG5qFAY8B3HLV 3XqWRFLAuPfx2YvM0iJz+bAewFlnJR0ZIj7lXY6ynQ6dtzVy6jW4cwD5btsCRZklahui EKI7+pBb+0VEppQNfHcGKop5mr8Ed62ZgpIby5/Q8jHshdudQJyMwxrw6x47vvMu5ty5 2NOl4atkpjyUIfW7lt7JIo4Fsqio8T1ZZsKMVdLh0Ps7xixAEkbD8NzQo//w7rUhxGtl Bp+Q== X-Gm-Message-State: ACrzQf31pEixDwv2kzh0we02Jqgqw/37arH4kFIM6aMfVmHjim+fMw02 254hzqRXry/aQqIfHSE2D4iVCZD5EOtaiQ== X-Google-Smtp-Source: AMsMyM7CX6D4SczzMRdtdtm0rd7ySe1A20nzzLDUu/TnuQ0JQ+xUbsrbn/PKGZrkA8gC1fJ8lzABNA== X-Received: by 2002:a5d:64a2:0:b0:230:c757:e3db with SMTP id m2-20020a5d64a2000000b00230c757e3dbmr26083070wrp.495.1666716004123; Tue, 25 Oct 2022 09:40:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/30] target/arm: Add ptw_idx to S1Translate Date: Tue, 25 Oct 2022 17:39:30 +0100 Message-Id: <20221025163952.4131046-9-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666717773625100003 From: Richard Henderson Hoist the computation of the mmu_idx for the ptw up to get_phys_addr_with_struct and get_phys_addr_twostage. This removes the duplicate check for stage2 disabled from the middle of the walk, performing it only once. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-id: 20221024051851.3074715-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 71 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 32d64125865..3c153f68318 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -17,6 +17,7 @@ =20 typedef struct S1Translate { ARMMMUIdx in_mmu_idx; + ARMMMUIdx in_ptw_idx; bool in_secure; bool in_debug; bool out_secure; @@ -214,33 +215,24 @@ static bool S1_ptw_translate(CPUARMState *env, S1Tran= slate *ptw, { bool is_secure =3D ptw->in_secure; ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; - ARMMMUIdx s2_mmu_idx =3D is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_St= age2; - bool s2_phys =3D false; + ARMMMUIdx s2_mmu_idx =3D ptw->in_ptw_idx; uint8_t pte_attrs; bool pte_secure; =20 - if (!arm_mmu_idx_is_stage1_of_2(mmu_idx) - || regime_translation_disabled(env, s2_mmu_idx, is_secure)) { - s2_mmu_idx =3D is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS; - s2_phys =3D true; - } - if (unlikely(ptw->in_debug)) { /* * From gdbstub, do not use softmmu so that we don't modify the * state of the cpu at all, including softmmu tlb contents. */ - if (s2_phys) { - ptw->out_phys =3D addr; - pte_attrs =3D 0; - pte_secure =3D is_secure; - } else { + if (regime_is_stage2(s2_mmu_idx)) { S1Translate s2ptw =3D { .in_mmu_idx =3D s2_mmu_idx, + .in_ptw_idx =3D is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_P= hys_NS, .in_secure =3D is_secure, .in_debug =3D true, }; GetPhysAddrResult s2 =3D { }; + if (!get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD, false, &s2, fi)) { goto fail; @@ -248,6 +240,11 @@ static bool S1_ptw_translate(CPUARMState *env, S1Trans= late *ptw, ptw->out_phys =3D s2.f.phys_addr; pte_attrs =3D s2.cacheattrs.attrs; pte_secure =3D s2.f.attrs.secure; + } else { + /* Regime is physical. */ + ptw->out_phys =3D addr; + pte_attrs =3D 0; + pte_secure =3D is_secure; } ptw->out_host =3D NULL; } else { @@ -268,7 +265,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, pte_secure =3D full->attrs.secure; } =20 - if (!s2_phys) { + if (regime_is_stage2(s2_mmu_idx)) { uint64_t hcr =3D arm_hcr_el2_eff_secstate(env, is_secure); =20 if ((hcr & HCR_PTW) && S2_attrs_are_device(hcr, pte_attrs)) { @@ -1263,7 +1260,18 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, descaddr |=3D (address >> (stride * (4 - level))) & indexmask; descaddr &=3D ~7ULL; nstable =3D extract32(tableattrs, 4, 1); - ptw->in_secure =3D !nstable; + if (!nstable) { + /* + * Stage2_S -> Stage2 or Phys_S -> Phys_NS + * Assert that the non-secure idx are even, and relative order. + */ + QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) !=3D 0); + QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) !=3D 0); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 !=3D ARMMMUIdx_Phys_S); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 !=3D ARMMMUIdx_Stage2_S= ); + ptw->in_ptw_idx &=3D ~1; + ptw->in_secure =3D false; + } descriptor =3D arm_ldq_ptw(env, ptw, descaddr, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; @@ -2449,6 +2457,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, =20 is_el0 =3D ptw->in_mmu_idx =3D=3D ARMMMUIdx_Stage1_E0; ptw->in_mmu_idx =3D s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Sta= ge2; + ptw->in_ptw_idx =3D s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_= NS; ptw->in_secure =3D s2walk_secure; =20 /* @@ -2508,10 +2517,32 @@ static bool get_phys_addr_with_struct(CPUARMState *= env, S1Translate *ptw, ARMMMUFaultInfo *fi) { ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; - ARMMMUIdx s1_mmu_idx =3D stage_1_mmu_idx(mmu_idx); bool is_secure =3D ptw->in_secure; + ARMMMUIdx s1_mmu_idx; =20 - if (mmu_idx !=3D s1_mmu_idx) { + switch (mmu_idx) { + case ARMMMUIdx_Phys_S: + case ARMMMUIdx_Phys_NS: + /* Checking Phys early avoids special casing later vs regime_el. */ + return get_phys_addr_disabled(env, address, access_type, mmu_idx, + is_secure, result, fi); + + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_Stage1_E1_PAN: + /* First stage lookup uses second stage for ptw. */ + ptw->in_ptw_idx =3D is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Sta= ge2; + break; + + case ARMMMUIdx_E10_0: + s1_mmu_idx =3D ARMMMUIdx_Stage1_E0; + goto do_twostage; + case ARMMMUIdx_E10_1: + s1_mmu_idx =3D ARMMMUIdx_Stage1_E1; + goto do_twostage; + case ARMMMUIdx_E10_1_PAN: + s1_mmu_idx =3D ARMMMUIdx_Stage1_E1_PAN; + do_twostage: /* * Call ourselves recursively to do the stage 1 and then stage 2 * translations if mmu_idx is a two-stage regime, and EL2 present. @@ -2522,6 +2553,12 @@ static bool get_phys_addr_with_struct(CPUARMState *e= nv, S1Translate *ptw, return get_phys_addr_twostage(env, ptw, address, access_type, result, fi); } + /* fall through */ + + default: + /* Single stage and second stage uses physical for ptw. */ + ptw->in_ptw_idx =3D is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_= NS; + break; } =20 /* --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716596; cv=none; d=zohomail.com; s=zohoarc; b=l6xuG/EzXwmo2By28dwbo1KZgAd5IXJ0GQnmfuKjMQLokIg5EXndJigyYwj/+8X05ytaP8/4iGx2lOc8MFxAR9/EIwsxzkMpi+Q8XSy8HdQGY3AmZ2et7plK5nZU0yJ5QF/t/Yu9wXzItaQiCah9fdLh31xXWxA1Og1cD82cG5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716596; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ppG/EzB7l5bDKZ2NX6MJRQhjOOzL6dQ8KubnemNVd/Y=; b=GOxrihbntcjxFb2YsmZLscrWpCIrxYs69+lk+xPsnjq5HFmAHrRfaSzCTkfIjlMlOfMpb7jZaDimBJrA98Fe+y2JxQljhVsitwHCzLvFIGl4QqCo5jva6190uDw4ppqVvjbOe0UhEkzP6lYwmNNcfkam/Se2QfJ4roGiAK1kNgg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716596213374.3331446621181; Tue, 25 Oct 2022 09:49:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyP-0005cT-D4; Tue, 25 Oct 2022 12:40:17 -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 1onMyI-0005Og-MH for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:13 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyE-0001OR-1H for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:10 -0400 Received: by mail-wr1-x431.google.com with SMTP id z14so8565379wrn.7 for ; Tue, 25 Oct 2022 09:40:05 -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.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:04 -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=ppG/EzB7l5bDKZ2NX6MJRQhjOOzL6dQ8KubnemNVd/Y=; b=DK8N6ZXSKIcjtIvkiENAftifoYD5iiqrKJDoSrY2E68GMr9Dh42isgEbeUYilx3Fmq RF+u5WN07I3NlTjkvsfG3zYfSi0+O06jQ6pJWquo6MyqzZ2IHhbI4C6p6rl3JATllKJ+ faA8sQ8iU0SCM95aJVHqfSBzdlvIA96SU84dnBoC6p54hu/5g5Wi9toDxM7CeTgvWk8s pZeKpocoFWFDolWHVB5u5pOBy8Fb+Tbzp09nc9tGSZvq6iuGcPpIFgGPMzzCQVPGsDRC wDqAHfvdfKtjEDzRBQavTcb4BITnxjjLhNhqA/DinAa8BvBlMkaQDiGc+rx1P+B7sbjP lAmg== 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=ppG/EzB7l5bDKZ2NX6MJRQhjOOzL6dQ8KubnemNVd/Y=; b=NO1Oi8AC1Ir5zxY0r6eDTlUYo8BSF1+EG/oXWpCQcV+X8bKeERzqKlYT1OOwcE/4xf M9rIKgTgm7Fivwc5J3YYSqUmWlarh5BgOF02VWqrVTn+zNALR1bAQdRU6smFphxrQ8A9 19OSlktShaAoUSInBc5LWNA3Bz1Eyi6+4kYD6LDFZVUtX0kyKP1f2nzkJ1HWBF34omKQ B9q3Z0xxinz5ZyErL88pWWRdcMyUqXdeBAv5dPUsjnE5EFMQnwJL5DAHu3hwfXLS4BB1 pv2Dr7mF0jpgnXrk5NGxpR04iELKUfZsjEpzEnrGsk8Ufcjd7RxhraUEh9F8cQwR0L7w 10Ig== X-Gm-Message-State: ACrzQf2RzP9cs9gvJAj5EQeahXPVJIzQ/FZ73/FiWU9wSdfPDIWFrcbe nk4apsvaB5HDwyzhIURfvnmiQ8KfYb6X5A== X-Google-Smtp-Source: AMsMyM6MyXU/0c5AT8FzV6rkajX2okhs4M4JCF5ZI+LG0dMA2c9IU55pQ98LuE3b/rz7ySyhWT42Mw== X-Received: by 2002:a5d:61c9:0:b0:236:781a:8d7e with SMTP id q9-20020a5d61c9000000b00236781a8d7emr6194561wrv.576.1666716005317; Tue, 25 Oct 2022 09:40:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/30] target/arm: Add isar predicates for FEAT_HAFDBS Date: Tue, 25 Oct 2022 17:39:31 +0100 Message-Id: <20221025163952.4131046-10-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x431.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716598367100007 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The MMFR1 field may indicate support for hardware update of access flag alone, or access flag and dirty bit. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20221024051851.3074715-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index f8c59858063..592b4ffbad4 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -4144,6 +4144,16 @@ static inline bool isar_feature_aa64_e0pd(const ARMI= SARegisters *id) return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, E0PD) !=3D 0; } =20 +static inline bool isar_feature_aa64_hafs(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) !=3D 0; +} + +static inline bool isar_feature_aa64_hdbs(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HAFDBS) >=3D 2; +} + static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) !=3D 0; --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716709; cv=none; d=zohomail.com; s=zohoarc; b=McNmfCMTtk3tI3ckwoAuUPAXeucFV1peOUI9V082fDC16lLI57mBRTlqdHENEABqSIIfYFdtfFaqP2E+sE76pE11SQm93+BFgKVaSJE5jKWPWlrLlI833dBDUT+NCS5s19BiGPuRrU9e9wAJjEMhcJ8FSZrwn3/YXCG4tB/mcTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716709; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cE9BuRySLzXUtT827AuGuFYq2Ao/Gkg9V7+gcu2PIBE=; b=c8tDrHvoXJv6bkS+oTiQRy6NRxBepO6ZNN51gPFldP4gFvvTBQU5acQv2avqU91gYgq9aXhfI+kggMzOpgqH4yCScafxJSImWHbsOySI3Dg+7gBP9D7lCfnpi5bnQy7qiUw8hgXRJB2ZuxOeaFMZL+pSA7XqIa48Ok5rQsy6bn4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716709434844.087858664307; Tue, 25 Oct 2022 09:51:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyP-0005fK-Vw; Tue, 25 Oct 2022 12:40:18 -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 1onMyK-0005PU-UZ for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:12 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyF-0001bE-Th for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:12 -0400 Received: by mail-wr1-x42a.google.com with SMTP id o4so13849110wrq.6 for ; Tue, 25 Oct 2022 09:40:07 -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.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:05 -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=cE9BuRySLzXUtT827AuGuFYq2Ao/Gkg9V7+gcu2PIBE=; b=dWyrlrl/b/psAAXUYQI5AzS6eJ84bIa8ff7e8tPjkNnElmXN2yvgGP/fgZgrfBZCtt GwKSewg2zjVOPIbn2raJd2ZQM2fg2xdlzhtg3gsdc/G8BGyQbOfcltAyd4mgNidNfpv3 ctLuksSdzZtl/8qVePCl+ROQTzZUgNJOgMvCJycTu4CTQUKgKOyIs91nPw4mMKSrA8wE cjGYncMsyn5mYnKzWRuhWrvrDgMvPWDzBUoySZwXcYj9+TefAiny1NWjVCz7nEcyi3st oF19dIDRERRTgVd5GykAsRZtDk/l3EMGb0cqUwMaxWOa7G1IzMWJoVrzCKr2axOqCExO CJbA== 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=cE9BuRySLzXUtT827AuGuFYq2Ao/Gkg9V7+gcu2PIBE=; b=BhNQC0us44Gs9mckjBzGQ9TnotpKi84tRM1hz3u4S45e6BCwGqFga4ExAoJLj5iPHs DO3anblYNONeFeGwo9VoIu3dkR08o5sakMT7qOEqL2z2gt1Plju7kpQUwaG9fFMq6lOi mrTe5/riRPU021QmoCRnT+JD3/JnScHljmteQWZBkc8M8C2M88WkDnZDhMM/jhLtRiu6 VlTH/P7sf0AvhOXONL0PcvL2OLrk09wagZaJM6dkjnspd44gm+YsLSNt8PDs5KouqBej +X5hhH1/h0lRmgNb0j+frhxF9FFBTotgDVBqrs4t9S9nIIc3/9Enx3b6YwU/G1RRCby/ zk1w== X-Gm-Message-State: ACrzQf1YDimYuxqsRnInRQ4bSpkRiziHbsyKYG6y3Joni+X4gSJqHdxs 4ZmutO4G/C1FoD67oDyIZe7dJqbv1DjjIA== X-Google-Smtp-Source: AMsMyM5uFH0l0xlpJZ0kEg1quS6ccIymaIScZHsTdgA3hxpT/hyq0V5wrutosL/uZgQuGy9RSBfFQw== X-Received: by 2002:a05:6000:2c4:b0:231:1b8:154 with SMTP id o4-20020a05600002c400b0023101b80154mr27959694wry.378.1666716006495; Tue, 25 Oct 2022 09:40:06 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/30] target/arm: Extract HA and HD in aa64_va_parameters Date: Tue, 25 Oct 2022 17:39:32 +0100 Message-Id: <20221025163952.4131046-11-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716710942100003 From: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Message-id: 20221024051851.3074715-5-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 2 ++ target/arm/helper.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index abfb32d77c2..32ed37a05b6 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1065,6 +1065,8 @@ typedef struct ARMVAParameters { bool hpd : 1; bool tsz_oob : 1; /* tsz has been clamped to legal range */ bool ds : 1; + bool ha : 1; + bool hd : 1; ARMGranuleSize gran : 2; } ARMVAParameters; =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index 47afaec6b44..b070a20f1ad 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10470,7 +10470,7 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, ARMMMUIdx mmu_idx, bool data) { uint64_t tcr =3D regime_tcr(env, mmu_idx); - bool epd, hpd, tsz_oob, ds; + bool epd, hpd, tsz_oob, ds, ha, hd; int select, tsz, tbi, max_tsz, min_tsz, ps, sh; ARMGranuleSize gran; ARMCPU *cpu =3D env_archcpu(env); @@ -10489,6 +10489,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, epd =3D false; sh =3D extract32(tcr, 12, 2); ps =3D extract32(tcr, 16, 3); + ha =3D extract32(tcr, 21, 1) && cpu_isar_feature(aa64_hafs, cpu); + hd =3D extract32(tcr, 22, 1) && cpu_isar_feature(aa64_hdbs, cpu); ds =3D extract64(tcr, 32, 1); } else { bool e0pd; @@ -10514,6 +10516,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, e0pd =3D extract64(tcr, 56, 1); } ps =3D extract64(tcr, 32, 3); + ha =3D extract64(tcr, 39, 1) && cpu_isar_feature(aa64_hafs, cpu); + hd =3D extract64(tcr, 40, 1) && cpu_isar_feature(aa64_hdbs, cpu); ds =3D extract64(tcr, 59, 1); =20 if (e0pd && cpu_isar_feature(aa64_e0pd, cpu) && @@ -10586,6 +10590,8 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env= , uint64_t va, .hpd =3D hpd, .tsz_oob =3D tsz_oob, .ds =3D ds, + .ha =3D ha, + .hd =3D ha && hd, .gran =3D gran, }; } --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716690; cv=none; d=zohomail.com; s=zohoarc; b=PC1xuIYb2TNc3bNb4m879cmKKYCSYK9aw90H1bb8W+/u6a+htljM0JQZHhfNdciBqF8X1UVR6xAbh7fpN5bJQp+aMDd4sQGcnLJnY1slcVUy2Qfil5G/saq716V3oIydyXTOM8G9ahsd6zR2qpp9wEB2bqmtaFCV52qQGnEFJFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716690; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h6xCcu8StBL3pe5a7E0ohO4YG9jcw79bAXoYz4WfMPo=; b=S+DNH0bfi1kX6feUj7rmR0t6+ZFn6Z4vKfhC54PWRcWlFOULWTZnlLwt5u6FjYG8u5LnXLW3BtW1vQfvX2FSilDfPlVmjsGALegVNGJBxn7Cm1ucDxYP56jgEMB84AtsrDGl90sR0ZOXHuc/8u3OGPlWrBrsmc84n0SIAERzHt0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716690681554.0421467603976; Tue, 25 Oct 2022 09:51:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyc-000665-4C; Tue, 25 Oct 2022 12:40:30 -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 1onMyR-0005lA-L4 for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:19 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyI-0001bS-Lh for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:19 -0400 Received: by mail-wr1-x42d.google.com with SMTP id a14so19284926wru.5 for ; Tue, 25 Oct 2022 09:40:10 -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.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:06 -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=h6xCcu8StBL3pe5a7E0ohO4YG9jcw79bAXoYz4WfMPo=; b=RGjHJo4kPSLLAzBsez5vE7dhMLWDy7VIytb459BJOLf3eOjIxdZDO5N7C7hCZkBDHl Dsxy+pitYf+oALYoEqrWwVpDhzYKoQcHy9VYIoHBTD68dtSGaC0h8DZYaIusISSyMdsD Tr330WqnUAfdqqXR+9bFVQBq19wVkUByvhMjB7VsMFT7ZJHM22zBUc0LHzJcqMVp0GAq ziIQS4hTPCGytWi0V/XzSb9j+02blef6cpj1uT1mDLJ3GHhmI8ahxqX81ZmsrbgWIHkr ZAonVLkUZv9W1WgT5PFQAocpMsp9osDUAeY82lKODCDDfjaya2McS8/VURVEvw9NMsVU aXkw== 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=h6xCcu8StBL3pe5a7E0ohO4YG9jcw79bAXoYz4WfMPo=; b=XukQllgcTThbpPinvzn2YyESxOSnn+VdnRSB6hFY56dvl0d0Dku6R/YAcfrqHEbKbK ffNnQ54FV9jVhgpFswHBg/yUnD2zHi1Ght5BtJis1WtG9DpKGHGUyFwJwuDEmk1bAuXb VORIQ5g2S0zGo0BxY/jyn4L6EduXrwswFbBgM2Eqm71F82eVtqHEg2Y/XvXK4uuaAAlQ dGZC7XJWtD45sWVbzQG03UtZoEy02JRod3mAZIoMq+3VMW4Ss1p+Umr9de2O/9uNGHJl 9csUfWqCAFhbPYmvCCrWRmxFe3rU6upEE52kP3oQFA7woDSJjvj1enjz4/HBOI8DhtMx FlTw== X-Gm-Message-State: ACrzQf0NW7jFFztjFgVUnAt63JYPtrqe40tpMAQ1NbApJsG1c70NFvZv hHbyuKSr61i+S07UTIk9Reja84qTK16nag== X-Google-Smtp-Source: AMsMyM4EVNg8haU0jXbXOsGyMq7evedgDCy+TAfK3hfsWU5oR2xOoLVecqGS0/thVufdnSMQwMx3aQ== X-Received: by 2002:a5d:6185:0:b0:236:776f:2bed with SMTP id j5-20020a5d6185000000b00236776f2bedmr6279415wru.535.1666716008263; Tue, 25 Oct 2022 09:40:08 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/30] target/arm: Move S1_ptw_translate outside arm_ld[lq]_ptw Date: Tue, 25 Oct 2022 17:39:33 +0100 Message-Id: <20221025163952.4131046-12-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716692921100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Separate S1 translation from the actual lookup. Will enable lpae hardware updates. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20221024051851.3074715-6-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 3c153f68318..44341a9dbcb 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -300,18 +300,12 @@ static bool S1_ptw_translate(CPUARMState *env, S1Tran= slate *ptw, } =20 /* All loads done in the course of a page table walk go through here. */ -static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, hwaddr add= r, +static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); uint32_t data; =20 - if (!S1_ptw_translate(env, ptw, addr, fi)) { - /* Failure. */ - assert(fi->s1ptw); - return 0; - } - if (likely(ptw->out_host)) { /* Page tables are in RAM, and we have the host address. */ if (ptw->out_be) { @@ -339,18 +333,12 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Trans= late *ptw, hwaddr addr, return data; } =20 -static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, hwaddr add= r, +static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); uint64_t data; =20 - if (!S1_ptw_translate(env, ptw, addr, fi)) { - /* Failure. */ - assert(fi->s1ptw); - return 0; - } - if (likely(ptw->out_host)) { /* Page tables are in RAM, and we have the host address. */ if (ptw->out_be) { @@ -507,7 +495,10 @@ static bool get_phys_addr_v5(CPUARMState *env, S1Trans= late *ptw, fi->type =3D ARMFault_Translation; goto do_fault; } - desc =3D arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc =3D arm_ldl_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } @@ -545,7 +536,10 @@ static bool get_phys_addr_v5(CPUARMState *env, S1Trans= late *ptw, /* Fine pagetable. */ table =3D (desc & 0xfffff000) | ((address >> 8) & 0xffc); } - desc =3D arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc =3D arm_ldl_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } @@ -630,7 +624,10 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Trans= late *ptw, fi->type =3D ARMFault_Translation; goto do_fault; } - desc =3D arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc =3D arm_ldl_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } @@ -683,7 +680,10 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Trans= late *ptw, ns =3D extract32(desc, 3, 1); /* Lookup l2 entry. */ table =3D (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); - desc =3D arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc =3D arm_ldl_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } @@ -1272,7 +1272,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, ptw->in_ptw_idx &=3D ~1; ptw->in_secure =3D false; } - descriptor =3D arm_ldq_ptw(env, ptw, descaddr, fi); + if (!S1_ptw_translate(env, ptw, descaddr, fi)) { + goto do_fault; + } + descriptor =3D arm_ldq_ptw(env, ptw, fi); if (fi->type !=3D ARMFault_None) { goto do_fault; } --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716919; cv=none; d=zohomail.com; s=zohoarc; b=j++zHXaKbc+XUiZeSbbaEyjsSYuXVj9R7uKAzX6ezKG3C9w3swlmmiasrDK+Wh5NPEl4zSfRuROKFleXFu7SP9cyuAqLHZJnlsbmUkj+i830AUYFZkc+LWvR251B2I0NQYvyZsjG6hqGPOSSyDNdq0P7ZRndn03qlczyujgdRko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716919; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kcdTz5KtC6+lO1M7/1rmzl3kAUHeqqkP0AgtZ5C0qI8=; b=C45mZqwhxE5OM8P9Cs7JWN5/62ldYR97qpSf58yyatnT0QEWsesNRb+vkLi3VVg2rHIKdo7fK0mdROa+SSp+TUhqPJFg3A3flyJ8rQEljHSbR3MrN5B0u9Vb6z9RRd97S+Uy8CtzyETPVVWF7gIN8Mdog1TvBMZ2dRVqVKN9vBY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716919651666.478081705436; Tue, 25 Oct 2022 09:55:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMys-0006YO-Er; Tue, 25 Oct 2022 12:40:46 -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 1onMyg-0006Cj-1J for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:34 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyJ-0001bf-0o for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:27 -0400 Received: by mail-wr1-x42c.google.com with SMTP id k8so13425587wrh.1 for ; Tue, 25 Oct 2022 09:40:10 -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.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:08 -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=kcdTz5KtC6+lO1M7/1rmzl3kAUHeqqkP0AgtZ5C0qI8=; b=dXAXV4oui3BMXBtjxVepXyrwSfz6iMXOuu2S6CY0VW15Nt8Fvh0kvhL/9sjcrJJpyq ox3S6X/VvXOvscgHaHgqa795G23gKMNu3b2Z4x7zfCMRAMVmP93UURZzUbdaBmTaVlpW 7VfZ+rvozN33xBbOJyEAw10f2yqYzPhffmMj3DRle15fskTsN8r7EupLOAq0etSvuvOs bkskWhNESNVU1ita6FLnwupBUJgUXHkKt5KQz/DcGPC2tvg6dSeSaXIRu6E5XTH7lONo ncGGvl9PRmkNK5DBZN0NOtopp29A2W/515+8NF28EM3jyA44N1BzU/DqWYosiqBIMFmq nCJw== 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=kcdTz5KtC6+lO1M7/1rmzl3kAUHeqqkP0AgtZ5C0qI8=; b=oMyveT+lA0RDcvALhmrmMKT8EHQD899oeY6UQqlBlEWgu67ThOzeklYGXUTCtBghv6 /ZMuhz7amQI0YoA1/qmFoMUjdqfHPaMxrEd95mlHyRgqoII0/H3r4Nrjw/UY6WKN4lY8 VZ/UjNHRN48Mu3VIRSZgYmkgMCNkglyC9xEUJMcT8k8xmVYCu/aJzu54N0egf2pBmmLQ ARYr9x4ooXDQ4dZ7ziNs5bkbK3Gm126FAG0Q1k3akgHnm1Ta8whNO5wA1JIeHMECqOWO ifMh9k2bHpFiDjSNHbp/jnttWTAv77+RNF3fd0knkvKQX92M/XAJyZJ20lP8AaiVbK/X qhsg== X-Gm-Message-State: ACrzQf3YM2DnT5Anbku6iWZUGIxQ8rZ0ltc52mEHJM/qbaTe/wx+Hks2 FRbFndkUVCt+5EBb85v7S2ZSQ0avzzK4bg== X-Google-Smtp-Source: AMsMyM6XykZWmik8gfB2tJIoGAS6EIMKbZX2viU+Hzh0vz5gxJtFLZaSSMsPCu8S5xRcLPTZdYrWWQ== X-Received: by 2002:a05:6000:156e:b0:22e:6bf3:79d0 with SMTP id 14-20020a056000156e00b0022e6bf379d0mr26620589wrz.456.1666716009693; Tue, 25 Oct 2022 09:40:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/30] target/arm: Add ARMFault_UnsuppAtomicUpdate Date: Tue, 25 Oct 2022 17:39:34 +0100 Message-Id: <20221025163952.4131046-13-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716920171100005 From: Richard Henderson This fault type is to be used with FEAT_HAFDBS when the guest enables hw updates, but places the tables in memory where atomic updates are unsupported. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Message-id: 20221024051851.3074715-7-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/internals.h b/target/arm/internals.h index 32ed37a05b6..87d33e7b774 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -338,6 +338,7 @@ typedef enum ARMFaultType { ARMFault_AsyncExternal, ARMFault_Debug, ARMFault_TLBConflict, + ARMFault_UnsuppAtomicUpdate, ARMFault_Lockdown, ARMFault_Exclusive, ARMFault_ICacheMaint, @@ -524,6 +525,9 @@ static inline uint32_t arm_fi_to_lfsc(ARMMMUFaultInfo *= fi) case ARMFault_TLBConflict: fsc =3D 0x30; break; + case ARMFault_UnsuppAtomicUpdate: + fsc =3D 0x31; + break; case ARMFault_Lockdown: fsc =3D 0x34; break; --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716668; cv=none; d=zohomail.com; s=zohoarc; b=nyiJsI0zIvKKg+9qAUlgEUSQnSoHNazCNCy/29NeR0oKUxfkALnlSNJVyLiVsvYx7H3FFDCPvPXNO6bgD7Euy9Z5gln1UeI2ywVLZg7Z42/MbHKBmdkvZZywLflq36erEwzZwExo0Np40/0KiKt0issk53bmQT+NhvpI1pAD1YI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716668; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Jy38OXYCQ98pqcGTk+3UYaSE1la9YoouNlpjYxXXabg=; b=TejRnGly+xF/KWEC63jL43Dw9Gwy7GE7ts82DMSAoFc/WufulLIHZNN4kZG56UM9NoIjWgyWp154B/FnNa76cfl2emFn6iPEwRN1colU9QfkhFaC8/TMcHedehoyTc00FBi0DoIPblt1HHNgU3Ljxxwe4+H8lJf1aHtxMGDu3Sc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716668415349.2335490501192; Tue, 25 Oct 2022 09:51:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMz1-0006cF-1c; Tue, 25 Oct 2022 12:40:55 -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 1onMyg-0006Cz-4S for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:34 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyL-0001by-HJ for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:26 -0400 Received: by mail-wr1-x434.google.com with SMTP id a14so19285157wru.5 for ; Tue, 25 Oct 2022 09:40:12 -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.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:10 -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=Jy38OXYCQ98pqcGTk+3UYaSE1la9YoouNlpjYxXXabg=; b=nphElM4FfE0YthrlzuuYaQ39p2HP0rSKjoaXUFCyXaMAnkZ7S+Crkgj8M/vB+NOQAK vZJRNFRnf1LoZtDGASxk16iLMO2QVxT9In5HdMF5fxf3AxyN3nSUCrHaiw2sOXYhf11C DV445/GGOFAkRgr7mrVvPk+Z8svMRMA8dslFX0Tbzl13XGD+64RkTCFN5xP8jwqXXobW qJzm1O96hvAT1JxiAyZE6KJ4cpYALxSI21v4lop0iUffPKX91h+b8rvkzuvy1vKg9TG1 iYnRsTxSeMHheDeZ7a5Cdot85F6f0U9mLEyQ1S4SBwEsTkvmMT91XZYrHirko4CGt2o8 dYIw== 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=Jy38OXYCQ98pqcGTk+3UYaSE1la9YoouNlpjYxXXabg=; b=Xf6/C0PCirYIlsCwisd0uSd5/ve6fFv8R4T1ly1vhaXWjilgZoweRXfONo29VrEA7T 35oWEHn4KPcXXYB2barShBT5grErFOS6vJRseqciXSdhWSuabz4SY1m3QDp35pI2YJqf KNVZBhZGnBEPHa0eygpNGkdH9MN+kuDQ9slfXNvlqsNYbqruRQgq2Gp+2KVI75LqiuaI /e8pN+CWTeE4Sqywo0cofobPKEkQpbSPj8ZHgSdPXyM1vQr6NSNZfS+e3GvOqv1t1uMp +0gAZFhpx6j96Dar0tp5i88Cy8GgBadayj2UcvgsKtTaKCkoFJ8O195/2ByEylo9MWWI zI2g== X-Gm-Message-State: ACrzQf1B5953AK7nETl6pOEup3UwU8mal8rkviXruLAH2FJypZ5iGFCC 9Eb4MCa8O/uP6mNMvbHw3TbHWTXDJT7MaQ== X-Google-Smtp-Source: AMsMyM5Kz7iSzLtqF7+BFSBTxVxbCjZ5zWnMPE+cTJ+qckJL+kIowS4PpySWmS09VFY0n4Aq45vVSw== X-Received: by 2002:a5d:64c7:0:b0:22e:43a6:2801 with SMTP id f7-20020a5d64c7000000b0022e43a62801mr27166477wri.612.1666716010896; Tue, 25 Oct 2022 09:40:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/30] target/arm: Remove loop from get_phys_addr_lpae Date: Tue, 25 Oct 2022 17:39:35 +0100 Message-Id: <20221025163952.4131046-14-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716668809100005 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The unconditional loop was used both to iterate over levels and to control parsing of attributes. Use an explicit goto in both cases. While this appears less clean for iterating over levels, we will need to jump back into the middle of this loop for atomic updates, which is even uglier. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20221024051851.3074715-8-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 192 +++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 44341a9dbcb..2a5f0188357 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1061,6 +1061,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); bool guarded =3D false; + uint64_t descriptor; + bool nstable; =20 /* TODO: This code does not support shareability levels. */ if (aarch64) { @@ -1253,106 +1255,104 @@ static bool get_phys_addr_lpae(CPUARMState *env, = S1Translate *ptw, * bits at each step. */ tableattrs =3D is_secure ? 0 : (1 << 4); - for (;;) { - uint64_t descriptor; - bool nstable; - - descaddr |=3D (address >> (stride * (4 - level))) & indexmask; - descaddr &=3D ~7ULL; - nstable =3D extract32(tableattrs, 4, 1); - if (!nstable) { - /* - * Stage2_S -> Stage2 or Phys_S -> Phys_NS - * Assert that the non-secure idx are even, and relative order. - */ - QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) !=3D 0); - QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) !=3D 0); - QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 !=3D ARMMMUIdx_Phys_S); - QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 !=3D ARMMMUIdx_Stage2_S= ); - ptw->in_ptw_idx &=3D ~1; - ptw->in_secure =3D false; - } - if (!S1_ptw_translate(env, ptw, descaddr, fi)) { - goto do_fault; - } - descriptor =3D arm_ldq_ptw(env, ptw, fi); - if (fi->type !=3D ARMFault_None) { - goto do_fault; - } - - if (!(descriptor & 1) || - (!(descriptor & 2) && (level =3D=3D 3))) { - /* Invalid, or the Reserved level 3 encoding */ - goto do_fault; - } - - descaddr =3D descriptor & descaddrmask; =20 + next_level: + descaddr |=3D (address >> (stride * (4 - level))) & indexmask; + descaddr &=3D ~7ULL; + nstable =3D extract32(tableattrs, 4, 1); + if (!nstable) { /* - * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [15:12] - * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of - * descaddr are in [9:8]. Otherwise, if descaddr is out of range, - * raise AddressSizeFault. + * Stage2_S -> Stage2 or Phys_S -> Phys_NS + * Assert that the non-secure idx are even, and relative order. */ - if (outputsize > 48) { - if (param.ds) { - descaddr |=3D extract64(descriptor, 8, 2) << 50; - } else { - descaddr |=3D extract64(descriptor, 12, 4) << 48; - } - } else if (descaddr >> outputsize) { - fault_type =3D ARMFault_AddressSize; - goto do_fault; - } - - if ((descriptor & 2) && (level < 3)) { - /* - * Table entry. The top five bits are attributes which may - * propagate down through lower levels of the table (and - * which are all arranged so that 0 means "no effect", so - * we can gather them up by ORing in the bits at each level). - */ - tableattrs |=3D extract64(descriptor, 59, 5); - level++; - indexmask =3D indexmask_grainsize; - continue; - } - /* - * Block entry at level 1 or 2, or page entry at level 3. - * These are basically the same thing, although the number - * of bits we pull in from the vaddr varies. Note that although - * descaddrmask masks enough of the low bits of the descriptor - * to give a correct page or table address, the address field - * in a block descriptor is smaller; so we need to explicitly - * clear the lower bits here before ORing in the low vaddr bits. - */ - page_size =3D (1ULL << ((stride * (4 - level)) + 3)); - descaddr &=3D ~(hwaddr)(page_size - 1); - descaddr |=3D (address & (page_size - 1)); - /* Extract attributes from the descriptor */ - attrs =3D extract64(descriptor, 2, 10) - | (extract64(descriptor, 52, 12) << 10); - - if (regime_is_stage2(mmu_idx)) { - /* Stage 2 table descriptors do not include any attribute fiel= ds */ - break; - } - /* Merge in attributes from table descriptors */ - attrs |=3D nstable << 3; /* NS */ - guarded =3D extract64(descriptor, 50, 1); /* GP */ - if (param.hpd) { - /* HPD disables all the table attributes except NSTable. */ - break; - } - attrs |=3D extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ - /* - * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] =3D= =3D 1 - * means "force PL1 access only", which means forcing AP[1] to 0. - */ - attrs &=3D ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] =3D> = AP[1] */ - attrs |=3D extract32(tableattrs, 3, 1) << 5; /* APT[1] =3D> A= P[2] */ - break; + QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) !=3D 0); + QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) !=3D 0); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 !=3D ARMMMUIdx_Phys_S); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 !=3D ARMMMUIdx_Stage2_S); + ptw->in_ptw_idx &=3D ~1; + ptw->in_secure =3D false; } + if (!S1_ptw_translate(env, ptw, descaddr, fi)) { + goto do_fault; + } + descriptor =3D arm_ldq_ptw(env, ptw, fi); + if (fi->type !=3D ARMFault_None) { + goto do_fault; + } + + if (!(descriptor & 1) || (!(descriptor & 2) && (level =3D=3D 3))) { + /* Invalid, or the Reserved level 3 encoding */ + goto do_fault; + } + + descaddr =3D descriptor & descaddrmask; + + /* + * For FEAT_LPA and PS=3D6, bits [51:48] of descaddr are in [15:12] + * of descriptor. For FEAT_LPA2 and effective DS, bits [51:50] of + * descaddr are in [9:8]. Otherwise, if descaddr is out of range, + * raise AddressSizeFault. + */ + if (outputsize > 48) { + if (param.ds) { + descaddr |=3D extract64(descriptor, 8, 2) << 50; + } else { + descaddr |=3D extract64(descriptor, 12, 4) << 48; + } + } else if (descaddr >> outputsize) { + fault_type =3D ARMFault_AddressSize; + goto do_fault; + } + + if ((descriptor & 2) && (level < 3)) { + /* + * Table entry. The top five bits are attributes which may + * propagate down through lower levels of the table (and + * which are all arranged so that 0 means "no effect", so + * we can gather them up by ORing in the bits at each level). + */ + tableattrs |=3D extract64(descriptor, 59, 5); + level++; + indexmask =3D indexmask_grainsize; + goto next_level; + } + + /* + * Block entry at level 1 or 2, or page entry at level 3. + * These are basically the same thing, although the number + * of bits we pull in from the vaddr varies. Note that although + * descaddrmask masks enough of the low bits of the descriptor + * to give a correct page or table address, the address field + * in a block descriptor is smaller; so we need to explicitly + * clear the lower bits here before ORing in the low vaddr bits. + */ + page_size =3D (1ULL << ((stride * (4 - level)) + 3)); + descaddr &=3D ~(hwaddr)(page_size - 1); + descaddr |=3D (address & (page_size - 1)); + /* Extract attributes from the descriptor */ + attrs =3D extract64(descriptor, 2, 10) + | (extract64(descriptor, 52, 12) << 10); + + if (regime_is_stage2(mmu_idx)) { + /* Stage 2 table descriptors do not include any attribute fields */ + goto skip_attrs; + } + /* Merge in attributes from table descriptors */ + attrs |=3D nstable << 3; /* NS */ + guarded =3D extract64(descriptor, 50, 1); /* GP */ + if (param.hpd) { + /* HPD disables all the table attributes except NSTable. */ + goto skip_attrs; + } + attrs |=3D extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ + /* + * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] =3D=3D 1 + * means "force PL1 access only", which means forcing AP[1] to 0. + */ + attrs &=3D ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] =3D> AP[1= ] */ + attrs |=3D extract32(tableattrs, 3, 1) << 5; /* APT[1] =3D> AP[2]= */ + skip_attrs: + /* * Here descaddr is the final physical address, and attributes * are all in attrs. --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716594; cv=none; d=zohomail.com; s=zohoarc; b=gjF4dQQ4oDOEQmNODcmWwalfbEPHjhW/TxhYrGkhUhWAhxGUU3hle+P/pQZdaUaEo3rKD1RrBgANRIpvVuV3NuryNBIUkQWRqf97JXS9VdLrtjMR4ONCy9hUfAx2WJ6Neyg/zxhlYFCc6kmHotzOK2hRJgsMoVljjUL00BKuJSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716593; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AbaC8j7lSp9Xzob/VbyJAgzqpmUf06lrerwAPEuh6PU=; b=aMOOwPBItV2jeoBxNjfOUlZauq6uf/hB80D0pdOSVtwLURQtDdc6h7iIjY/HQsxaJzfgHDwpZR/z+qBrkOtzinKkzwSrDRlZ76FBR2rtRopB6ntxtY0Unq1aHEETlphjjW7yV1Vbpy9aiX9zEADSYQjpvVF8p8Xd6sNeMH4e6b8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716593992281.76345087219113; Tue, 25 Oct 2022 09:49:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyr-0006UH-DP; Tue, 25 Oct 2022 12:40:45 -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 1onMyg-0006Cm-1p for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:34 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyM-0001cF-ML for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:24 -0400 Received: by mail-wm1-x335.google.com with SMTP id n14so4242064wmq.3 for ; Tue, 25 Oct 2022 09:40:13 -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.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:11 -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=AbaC8j7lSp9Xzob/VbyJAgzqpmUf06lrerwAPEuh6PU=; b=p/E0v1XvaWp06Wvwq3qPHFZkUb8WNrHB8oQsIyBU583B3s9b1KHdzGRkuXyoZjXtht KHQj/r5/jep+ZBlrzjknd0vIbz568fIUyYb9c9ebd9OvyCvWxcRpXQOQJQ9fZTWX/RGm Q1WEI9uomkcV5X3VZNBnwMJoM2ULAn5+PvuDs3waVRnT00JCyyyuekBggZoFNBXPh0nD tDPKQxs34D7NStJLhiBTSS0/O6G/PmQYrkq/GqkmzKfJEz+hdvEOZXpWLUY/6yaR78/A RmPArJ7WAIlm/chl064aMGzws6Tr60x0oE0uGgi7LxbixGs5Shj7IqGokV5WWmGbI6at ZVDg== 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=AbaC8j7lSp9Xzob/VbyJAgzqpmUf06lrerwAPEuh6PU=; b=FajoKLk4ASf/VfQ6bqMVI03rn2fLwN+4/5pM8enOM1Cu4QfFXqbqIwWJ5rH/t2uddR zZOUqze4yw4RS0OqoMlyIl+jJAEg0vdbtrbwlQhA3aQh9iwEUlDYNJOd9wXSNIx7VS7V 7YUITus26kVfJ/W3y1dQq7nLG2QcOFIvKLiWho3v42DIVWo8LBmGVziD65+rOAr4oy3e HlUeIz3kb4y2Bpf07JZy0Vr7C9pcgvxLsApkmd96JR32FE7e1rQydEWF5HjWqF9G4l60 A5ClDVWYAwyPZ1U5erPZCX4VUU2cGQ3ov8MCZn7PGUHk7ebSd4QK6GjcB5GoKEJFD37I bRFQ== X-Gm-Message-State: ACrzQf05gM/fOewwi+iyvIg65XN490lT5RQ/P0SsuMI/cKiy+zrO9JvG VXnRESDZtmx+9GCM9OEB3l40+PFJS2mP2w== X-Google-Smtp-Source: AMsMyM4+8W4zhuZ3OF0jxo6D/XrY5VhLBcVEcBjmv4RktfwbaYY0Yvoq5XMSRXvbVukjavIYd0m3RA== X-Received: by 2002:a05:600c:3107:b0:3c6:ff0a:c42 with SMTP id g7-20020a05600c310700b003c6ff0a0c42mr25797684wmo.141.1666716012108; Tue, 25 Oct 2022 09:40:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/30] target/arm: Fix fault reporting in get_phys_addr_lpae Date: Tue, 25 Oct 2022 17:39:36 +0100 Message-Id: <20221025163952.4131046-15-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716594430100001 From: Richard Henderson Always overriding fi->type was incorrect, as we would not properly propagate the fault type from S1_ptw_translate, or arm_ldq_ptw. Simplify things by providing a new label for a translation fault. For other faults, store into fi directly. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Message-id: 20221024051851.3074715-9-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 2a5f0188357..3302376e42e 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1044,8 +1044,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, ARMCPU *cpu =3D env_archcpu(env); ARMMMUIdx mmu_idx =3D ptw->in_mmu_idx; bool is_secure =3D ptw->in_secure; - /* Read an LPAE long-descriptor translation table. */ - ARMFaultType fault_type =3D ARMFault_Translation; uint32_t level; ARMVAParameters param; uint64_t ttbr; @@ -1082,8 +1080,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * so our choice is to always raise the fault. */ if (param.tsz_oob) { - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } =20 addrsize =3D 64 - 8 * param.tbi; @@ -1120,8 +1117,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, addrsize - inputsize); if (-top_bits !=3D param.select) { /* The gap between the two regions is a Translation fault */ - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } } =20 @@ -1147,7 +1143,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * Translation table walk disabled =3D> Translation fault on TLB m= iss * Note: This is always 0 on 64-bit EL2 and EL3. */ - goto do_fault; + goto do_translation_fault; } =20 if (!regime_is_stage2(mmu_idx)) { @@ -1178,8 +1174,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, if (param.ds && stride =3D=3D 9 && sl2) { if (sl0 !=3D 0) { level =3D 0; - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } startlevel =3D -1; } else if (!aarch64 || stride =3D=3D 9) { @@ -1198,8 +1193,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, ok =3D check_s2_mmu_setup(cpu, aarch64, startlevel, inputsize, stride, outputsize); if (!ok) { - fault_type =3D ARMFault_Translation; - goto do_fault; + goto do_translation_fault; } level =3D startlevel; } @@ -1221,7 +1215,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, descaddr |=3D extract64(ttbr, 2, 4) << 48; } else if (descaddr >> outputsize) { level =3D 0; - fault_type =3D ARMFault_AddressSize; + fi->type =3D ARMFault_AddressSize; goto do_fault; } =20 @@ -1282,7 +1276,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, =20 if (!(descriptor & 1) || (!(descriptor & 2) && (level =3D=3D 3))) { /* Invalid, or the Reserved level 3 encoding */ - goto do_fault; + goto do_translation_fault; } =20 descaddr =3D descriptor & descaddrmask; @@ -1300,7 +1294,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, descaddr |=3D extract64(descriptor, 12, 4) << 48; } } else if (descaddr >> outputsize) { - fault_type =3D ARMFault_AddressSize; + fi->type =3D ARMFault_AddressSize; goto do_fault; } =20 @@ -1357,9 +1351,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, * Here descaddr is the final physical address, and attributes * are all in attrs. */ - fault_type =3D ARMFault_AccessFlag; if ((attrs & (1 << 8)) =3D=3D 0) { /* Access flag */ + fi->type =3D ARMFault_AccessFlag; goto do_fault; } =20 @@ -1376,8 +1370,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, p= xn); } =20 - fault_type =3D ARMFault_Permission; if (!(result->f.prot & (1 << access_type))) { + fi->type =3D ARMFault_Permission; goto do_fault; } =20 @@ -1422,8 +1416,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, result->f.lg_page_size =3D ctz64(page_size); return false; =20 -do_fault: - fi->type =3D fault_type; + do_translation_fault: + fi->type =3D ARMFault_Translation; + do_fault: fi->level =3D level; /* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */ fi->stage2 =3D fi->s1ptw || regime_is_stage2(mmu_idx); --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666717356; cv=none; d=zohomail.com; s=zohoarc; b=nv+M+3E5G72vymO5O0MNtrXK8Ro0SgqhYVyBNi91a+dVhEWuICpWQDnD9CcEeX8KkkKbiokq9xb2s3PpTJH2MNLEAkP5/+gMKuWkkuSyumjMHSfLUIT1aMAYrFDYlY2QK+oAl3v142mrqqM2OJpbKKu0y13hiprs2la7HRd6S1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666717356; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v7FsAg0HK2uUkzX8X5S4y/tawsKHcfFIVqGsDHnAE08=; b=JwUbvZXAh5+VSAdgACxBn0tVcIRZzgOsSbCdquWZn9ebLZoUChkrpa1qhcpLLr3bIsATGIMwypzI3gKF8wWrAEYz8s19ltUaP0usko6U2ujsScj/j8duaL+JhCF9PntpMjiyXNYJ2RzUtLuP+A1xczZbnnFM/SlTowvOGgITdz4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666717356795239.5263427680926; Tue, 25 Oct 2022 10:02:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMye-000696-VO; Tue, 25 Oct 2022 12:40:32 -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 1onMyR-0005lH-Ua for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:19 -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 1onMyM-0001cR-Go for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:18 -0400 Received: by mail-wr1-x436.google.com with SMTP id bp11so21528064wrb.9 for ; Tue, 25 Oct 2022 09:40:14 -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.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:12 -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=v7FsAg0HK2uUkzX8X5S4y/tawsKHcfFIVqGsDHnAE08=; b=E1btpO2tArXJ3d3rcojJ9KDEh664HfH2OLNnSxGefQRHKvAOpsmY9jPwpmXL1Rs3D4 fAqDynnYu5ioQhX/6OseXAKOe77oaOGOF0HbENfAdegTU1d3t2Xs/g/vUXJReGhQju++ nRF+ZFwR2JbyIs6iGh9XoPVdueXBHGOuYFyfpvQ1N1Mrp9VwOaHpjqltaNL8zqCp5dYi M1AcOMIQDtOCO3X2C8UgYD+uvtsk8zg7dQLjmDbs1Eg5E8IrCNQEg8vd1b1/T7a6XDA3 junE+rpKWOVK1lALdNgdfAC4CYljCiL2eNXISBL3F+f0q+Ety9wK9hctVs/7anJwcPA6 nt9w== 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=v7FsAg0HK2uUkzX8X5S4y/tawsKHcfFIVqGsDHnAE08=; b=n9agsCGE2ojYSac6g20xoB3KYXnOfmbZJTL7hLp2FjOHUB8Prvi/KhEuKFOYCOSI6X EL9iGTatkp7c11X76YpFs39ep73+Mmz/jRjOIogSujpOZHApPw8nD+Sq0vhAL9WoDbTc 6w4ilLfn5U1XI0DqFk4wnT0Xv8rW+DTh7kKkUWT2Xze7N5eA5Iqo5UGONiqumFhEQ8QV 0RhQEsnz3MR8T8mYPAOV3al308gKgfyBDA/TVQGLB3vzk13mKGhXjrnqASS8rYATmIVO 2ZbQNwwhuIIC99v0hgvuc126b4ifWt86QaqV96G4d882jXLQqD6PyrQCVV48E9trxBDU XCAQ== X-Gm-Message-State: ACrzQf1++and+KsaWika2HdXbk4maW27uO1Tc8WmnAucLT2GNmHrGMB5 tE5BAlsXlaETPgA/fMa8gASRWkQ7fVZ17w== X-Google-Smtp-Source: AMsMyM6dTDSge/CFBTnMGevGQYXlxMIeaZeRulr0EZpy9FP7NEJyf6ysaXTniY7Gr9CO0+5WV1XOCw== X-Received: by 2002:adf:d1ca:0:b0:236:737f:8dfa with SMTP id b10-20020adfd1ca000000b00236737f8dfamr7229293wrd.588.1666716013222; Tue, 25 Oct 2022 09:40:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/30] target/arm: Don't shift attrs in get_phys_addr_lpae Date: Tue, 25 Oct 2022 17:39:37 +0100 Message-Id: <20221025163952.4131046-16-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666717359057100003 From: Richard Henderson Leave the upper and lower attributes in the place they originate from in the descriptor. Shifting them around is confusing, since one cannot read the bit numbers out of the manual. Also, new attributes have been added which would alter the shifts. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20221024051851.3074715-10-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 3302376e42e..691110f70c0 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1050,7 +1050,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, hwaddr descaddr, indexmask, indexmask_grainsize; uint32_t tableattrs; target_ulong page_size; - uint32_t attrs; + uint64_t attrs; int32_t stride; int addrsize, inputsize, outputsize; uint64_t tcr =3D regime_tcr(env, mmu_idx); @@ -1324,49 +1324,48 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, descaddr &=3D ~(hwaddr)(page_size - 1); descaddr |=3D (address & (page_size - 1)); /* Extract attributes from the descriptor */ - attrs =3D extract64(descriptor, 2, 10) - | (extract64(descriptor, 52, 12) << 10); + attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(52, 1= 2)); =20 if (regime_is_stage2(mmu_idx)) { /* Stage 2 table descriptors do not include any attribute fields */ goto skip_attrs; } /* Merge in attributes from table descriptors */ - attrs |=3D nstable << 3; /* NS */ + attrs |=3D nstable << 5; /* NS */ guarded =3D extract64(descriptor, 50, 1); /* GP */ if (param.hpd) { /* HPD disables all the table attributes except NSTable. */ goto skip_attrs; } - attrs |=3D extract32(tableattrs, 0, 2) << 11; /* XN, PXN */ + attrs |=3D extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ /* * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] =3D=3D 1 * means "force PL1 access only", which means forcing AP[1] to 0. */ - attrs &=3D ~(extract32(tableattrs, 2, 1) << 4); /* !APT[0] =3D> AP[1= ] */ - attrs |=3D extract32(tableattrs, 3, 1) << 5; /* APT[1] =3D> AP[2]= */ + attrs &=3D ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] =3D> AP[1= ] */ + attrs |=3D extract32(tableattrs, 3, 1) << 7; /* APT[1] =3D> AP[2]= */ skip_attrs: =20 /* * Here descaddr is the final physical address, and attributes * are all in attrs. */ - if ((attrs & (1 << 8)) =3D=3D 0) { + if ((attrs & (1 << 10)) =3D=3D 0) { /* Access flag */ fi->type =3D ARMFault_AccessFlag; goto do_fault; } =20 - ap =3D extract32(attrs, 4, 2); + ap =3D extract32(attrs, 6, 2); =20 if (regime_is_stage2(mmu_idx)) { ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; - xn =3D extract32(attrs, 11, 2); + xn =3D extract64(attrs, 53, 2); result->f.prot =3D get_S2prot(env, ap, xn, s1_is_el0); } else { - ns =3D extract32(attrs, 3, 1); - xn =3D extract32(attrs, 12, 1); - pxn =3D extract32(attrs, 11, 1); + ns =3D extract32(attrs, 5, 1); + xn =3D extract64(attrs, 54, 1); + pxn =3D extract64(attrs, 53, 1); result->f.prot =3D get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, p= xn); } =20 @@ -1391,10 +1390,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, =20 if (regime_is_stage2(mmu_idx)) { result->cacheattrs.is_s2_format =3D true; - result->cacheattrs.attrs =3D extract32(attrs, 0, 4); + result->cacheattrs.attrs =3D extract32(attrs, 2, 4); } else { /* Index into MAIR registers for cache attributes */ - uint8_t attrindx =3D extract32(attrs, 0, 3); + uint8_t attrindx =3D extract32(attrs, 2, 3); uint64_t mair =3D env->cp15.mair_el[regime_el(env, mmu_idx)]; assert(attrindx <=3D 7); result->cacheattrs.is_s2_format =3D false; @@ -1409,7 +1408,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, if (param.ds) { result->cacheattrs.shareability =3D param.sh; } else { - result->cacheattrs.shareability =3D extract32(attrs, 6, 2); + result->cacheattrs.shareability =3D extract32(attrs, 8, 2); } =20 result->f.phys_addr =3D descaddr; --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716141; cv=none; d=zohomail.com; s=zohoarc; b=ZJHVC4V/vzwCdwedN5pIOnpYMDAMeX8sENbCpVN/Rjg/fmbUdee5FiyoBOqawkCK77xNvoQHTMWetmUUlLdYzCh2OfqctXGlMn6NSMFVRR93uYdYBwdaD11JDU2AONxfM5/qCTehjeriY0pJrG3xhWjlSsW8Ai87Y1jJLLI4kXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716141; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LwhUM2f4rGKe/Yiu4bKIyuH2Jgq3WPwiKOal14pJUNg=; b=C/HcdRrxqPrzL34HRkbmpnY+dPqQc/62c5V0adVTVqwHeblw7a3U4mRFj/gFCWoy73Si7vnAugbX8poCl3VPNOcz+Mif2Q0mt9mJShSQEtWbSN8uDqmYKvi9E5nh8YaRHPXYpcTmkpvn7zu0dgHBXAMVva7XykDN6QyW4Te7A9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716141095310.51437199222244; Tue, 25 Oct 2022 09:42:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyn-0006Ok-FX; Tue, 25 Oct 2022 12:40:41 -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 1onMyf-0006CV-Vc for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:34 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyN-0001ct-LW for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:23 -0400 Received: by mail-wm1-x32c.google.com with SMTP id y10so8521591wma.0 for ; Tue, 25 Oct 2022 09:40:15 -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.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:13 -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=LwhUM2f4rGKe/Yiu4bKIyuH2Jgq3WPwiKOal14pJUNg=; b=hjp+Lm+JYYB0Sb5ah1xzULH0SVE0wBm26sDGuchgWyIea8JuX6r6qYEOjKwIXmJnfY fIC4Xtmxii0slvA7GFgFQuch9S0j7ix3lPn0NimdYwg+RNic/DdfHS/tGq5UlT1EnIC1 ihqMujfe+2M1oOtP/LXCQEB6XyVnqAvcRJMruKAayWPmLTObzJEOeIk0c01ed+dEbxq1 qpas2VoyI3XKd76GhPl/R7I1BZ04MCUG3q036On6B6/Y47Kt0XPfwLNHB73eseAAOQID mNzmPC86Pq+4twuCsWAv1njl1y95YinhcwgiXD5chzVmz3FbTnaPv4iQc9uKJ2Vm2Gg4 z9mQ== 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=LwhUM2f4rGKe/Yiu4bKIyuH2Jgq3WPwiKOal14pJUNg=; b=z5/qGMWMKE8x5hLSXezbnOE7GQdHUkPaeqTLyg4nU7x0sc3LCRc/piDx1sMl1rQ2yE 2fJ+yxSwlWCavaYRfDFSaKJdSd/DxiJ/e4CIWSXX5Rh2o8nEXvzuvQzRLryI9E6M/vzX 7wPRoar7oFWJnb3oQzM3j8cBWSRKW64nfgJozR+1Ek3sXG1dDWz+VnkkCt4TAz3Wakid v6MFYyYgyLbf9lDmz6W67vUVFFmKEpuFUfW8Tfp6RF74qzopMCER0uw2pAreu/fIRFpm qLugc7h0d9QsS4JiypMRa38a26NGx1WxjFJnVyJCIibgNi0sWQlWigDMcq/wVBTclkFG x1Uw== X-Gm-Message-State: ACrzQf3CDZe0/aaNSEdGUw2uX46eMldif0RZ7A8vqa1rPfViRb8LCUnj 860n9vSF1jSV/9+allvMpp+EI7/PI4VZaA== X-Google-Smtp-Source: AMsMyM5F2JybaR5cnyunT1m0n9LB8c4BI96ATBH+vWnaTTLRoxrQBU2rczS+tSwAVVsYHb4w3fmTDA== X-Received: by 2002:a05:600c:3584:b0:3c6:f234:852b with SMTP id p4-20020a05600c358400b003c6f234852bmr34013872wmq.10.1666716014331; Tue, 25 Oct 2022 09:40:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/30] target/arm: Consider GP an attribute in get_phys_addr_lpae Date: Tue, 25 Oct 2022 17:39:38 +0100 Message-Id: <20221025163952.4131046-17-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716143220100003 From: Richard Henderson Both GP and DBM are in the upper attribute block. Extend the computation of attrs to include them, then simplify the setting of guarded. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Message-id: 20221024051851.3074715-11-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 691110f70c0..79a0ef45c79 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1058,7 +1058,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, uint32_t el =3D regime_el(env, mmu_idx); uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); - bool guarded =3D false; uint64_t descriptor; bool nstable; =20 @@ -1324,7 +1323,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, descaddr &=3D ~(hwaddr)(page_size - 1); descaddr |=3D (address & (page_size - 1)); /* Extract attributes from the descriptor */ - attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(52, 1= 2)); + attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 1= 4)); =20 if (regime_is_stage2(mmu_idx)) { /* Stage 2 table descriptors do not include any attribute fields */ @@ -1332,7 +1331,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, } /* Merge in attributes from table descriptors */ attrs |=3D nstable << 5; /* NS */ - guarded =3D extract64(descriptor, 50, 1); /* GP */ if (param.hpd) { /* HPD disables all the table attributes except NSTable. */ goto skip_attrs; @@ -1385,7 +1383,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, =20 /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. = */ if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { - result->f.guarded =3D guarded; + result->f.guarded =3D extract64(attrs, 50, 1); /* GP */ } =20 if (regime_is_stage2(mmu_idx)) { --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716390; cv=none; d=zohomail.com; s=zohoarc; b=Ft7slcgnYmRsUzZ7+7/fjcqkzCYh4SXMd57clqzkvWgwIbCLZbz0VZkyGqhZUB6pimJ+qlice4hdHGusHREaWAS9zHuk//gbdAD1YCo5yGsHJvFzWubDpizcBT59EjznqvOBgC5KHMC0dTNVPfCiXDg6Q00Jgx1nvhSWGGTitS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716390; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gxu0mniabCTeOPg3dGH8ocxPQsfgLf2PZIHByV3HkDY=; b=MqwBaBuDq22ODo+WhZc1WjSQt9z0x16tjc9L/6JxvYjx/sqn+dSYqlqUrY+aJM8nI9gwVDjbjRh58wlF3x9hOILcE3ThCql1/B7dFszfrtTTHDYzWSjCGDoiqje2EIRp3o/O9OzcWDj86c4IxcG9FeBXJ2tS8nCdt8f+eCwc/z0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716390833367.2511533765336; Tue, 25 Oct 2022 09:46:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyq-0006Th-6k; Tue, 25 Oct 2022 12:40:44 -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 1onMyg-0006Ck-1f for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:34 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyO-0001dB-RO for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:25 -0400 Received: by mail-wr1-x429.google.com with SMTP id bk15so22061269wrb.13 for ; Tue, 25 Oct 2022 09:40:16 -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.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:14 -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=gxu0mniabCTeOPg3dGH8ocxPQsfgLf2PZIHByV3HkDY=; b=jEBZSTplR+MxR0uq6vfPiEC2Z3YGy0W8YQWv50NrBCs1GdelKLz+2k2xmjoqEamjGG R8Qr5YjjfNbUIJtU9bVFmdYD0xA6+TdwDJabeJ5zqlGx/y7qhueTNRkSxI/dxBhj/wr2 0fKzYK+vQxDV7RpJAHvpFCQ2faT0/bs7BEpEd274M2+BuVhoS6jmTYoI+aVXuKEqQzt0 z219BJEXK8qJ5bdSOFXbaA1xajA9aEAl1vEP3BL1ShHAxADPDQ6lFfcdrvFGT3HgYXeh hbwjOtXef2tEK4MAsoCrI6OtY2Pvw4xu8GnL8BjK5+O/ZBpx5xPYYZBywdPagC7L+H62 K0pQ== 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=gxu0mniabCTeOPg3dGH8ocxPQsfgLf2PZIHByV3HkDY=; b=P+IzX3QgBAhwaUJ8nWDvEfKaLQNziq8Wd/aXPr8kr5u5z+FSQQCgfbi04D88pWuCSp GvIyZjR+SrrZHLcxmifU/r1pRm1W4yJ1ejWX1reqAvBBXZJ1pMtEoTz2zq6Yznk7SYXn XXh6+7WdLKcCWqBH1DEPcXbgwvwIPK/U2ib7QHbNBCuyB47g6tLAl/haEdoB9JzGvitc +krHCVE83Lm5cLbXMToLJQh1YLPjC4LW9W/Ea3mmORJkYrnqKG9xCti6nb75KA9sIs7f tt1W3pEOtHHz1E4G8PYZgUHhzjVEajBuo8caEtHM5lkMnrPokoF9p69W1FzhI2365eLn hpUQ== X-Gm-Message-State: ACrzQf0Sc+CEv+nsq3tGZdTeDZKTb/1bcpNvg3Ihj4cNGJLPAzEkdbxa LmqMQnQ7kCbX9+z/U6oqDiqb1d37yZYoNw== X-Google-Smtp-Source: AMsMyM7Q91F2vu9Ud3CX27YdO+l+QOjJny+YKb65By20wp1zZYo3hiqeiv9mNChZ9Rv/lITFuwQrDA== X-Received: by 2002:a05:6000:16c3:b0:22e:c6fd:2676 with SMTP id h3-20020a05600016c300b0022ec6fd2676mr25899358wrf.141.1666716015395; Tue, 25 Oct 2022 09:40:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/30] target/arm: Tidy merging of attributes from descriptor and table Date: Tue, 25 Oct 2022 17:39:39 +0100 Message-Id: <20221025163952.4131046-18-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716392425100003 From: Richard Henderson Replace some gotos with some nested if statements. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Message-id: 20221024051851.3074715-12-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 79a0ef45c79..73b3c37b23f 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1322,27 +1322,25 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, page_size =3D (1ULL << ((stride * (4 - level)) + 3)); descaddr &=3D ~(hwaddr)(page_size - 1); descaddr |=3D (address & (page_size - 1)); - /* Extract attributes from the descriptor */ - attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 1= 4)); =20 - if (regime_is_stage2(mmu_idx)) { - /* Stage 2 table descriptors do not include any attribute fields */ - goto skip_attrs; - } - /* Merge in attributes from table descriptors */ - attrs |=3D nstable << 5; /* NS */ - if (param.hpd) { - /* HPD disables all the table attributes except NSTable. */ - goto skip_attrs; - } - attrs |=3D extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ /* - * The sense of AP[1] vs APTable[0] is reversed, as APTable[0] =3D=3D 1 - * means "force PL1 access only", which means forcing AP[1] to 0. + * Extract attributes from the descriptor, and apply table descriptors. + * Stage 2 table descriptors do not include any attribute fields. + * HPD disables all the table attributes except NSTable. */ - attrs &=3D ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] =3D> AP[1= ] */ - attrs |=3D extract32(tableattrs, 3, 1) << 7; /* APT[1] =3D> AP[2]= */ - skip_attrs: + attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 1= 4)); + if (!regime_is_stage2(mmu_idx)) { + attrs |=3D nstable << 5; /* NS */ + if (!param.hpd) { + attrs |=3D extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ + /* + * The sense of AP[1] vs APTable[0] is reversed, as APTable[0]= =3D=3D 1 + * means "force PL1 access only", which means forcing AP[1] to= 0. + */ + attrs &=3D ~(extract64(tableattrs, 2, 1) << 6); /* !APT[0] =3D= > AP[1] */ + attrs |=3D extract32(tableattrs, 3, 1) << 7; /* APT[1] =3D>= AP[2] */ + } + } =20 /* * Here descaddr is the final physical address, and attributes --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716999; cv=none; d=zohomail.com; s=zohoarc; b=Abzqq+/Tt3ZVrC3Mo9uIP1teQWOMGX33egWF9mJHaTKZFQZe2eDtYr7rdXdVUjqGNz3inxuyKIdgPNV0g9qziVduGx0c4IhXJUCPk4GZAb3pmFLsnWgqeRd50/diLQ0fXdXMaTWyVeQG12hEyP/25bc1yGCaCzL0EleHRBu5hUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716999; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=syvb6lOf2ketormAVnCyzgEWolcoDj1zCWAiB10+6EU=; b=Swao8lTwcS68yfplEXQAKRYmhcAosTD3BOkqbe2nD4ttLOB4UT8jQXW5FZmm8sPOauvWKpaByFfdniDn/KTYGTINdUdfyuwyef5FRTeLwgC0zMwvMB55gMdU+omcRO/Pn1JqAfltZ0xNOgHk8udVXp8x1eCWglw1jEL40Cw3AwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716999233123.51247603748834; Tue, 25 Oct 2022 09:56:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMz1-0006fO-Q0; Tue, 25 Oct 2022 12:40:55 -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 1onMyg-0006Cr-2g for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:34 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyP-0001Q3-Cj for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:27 -0400 Received: by mail-wr1-x42f.google.com with SMTP id h9so10987674wrt.0 for ; Tue, 25 Oct 2022 09:40:16 -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.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:16 -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=syvb6lOf2ketormAVnCyzgEWolcoDj1zCWAiB10+6EU=; b=Rh1iIr4htKAJwpB4Eo85wETY+IjuVQ2J7lreviTnKGscDDH+0rJGfDoIp1xnI1erwC EvZKusJOtZVxAuryF8EgAV8tQjI5QQkI1pfTgY6H1mIQ+4t5/ycsJKnanaoV4OWEwVR5 YBxp7XxLcn61ztbN9AW8gTIfKf9H2Xu1bgOz/5UFyxTR0/mbQuj/NYICOE1cnzYEKuRw wDckwJUXRISGE0rpl5AgTnoDeXenbaXa0RzwT6ayqwp2znA81xyQr/dDlCYzm/IjelfA TVSwnNCA6K3m2EgMt6U1ZWCnSTariifzu2/LLhNrs6OBm031kB57H9VpVjRFqoCtURoK 92aQ== 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=syvb6lOf2ketormAVnCyzgEWolcoDj1zCWAiB10+6EU=; b=XduBXgYKnFgHY4+q+u5RVAtQCrakAbnF5f26bNju01Qa6m9dnWSL240pV+cPagOYpc yGOovV7O1XUSJUOsqzu+Wt0ZJ0XSA128yL2MaIz2BChN7FQf6LP1LvrOqnMcSfQCdCky 6GuhEqk/+gIXP3cKeHZRO2ZxIEZxLTm7WcODWK51CoCjMCJeRJdSxQpUtNGU9KhqX7L/ eRlTm+5KisXB/7JtqHSohAe4H55/RBnjCFdmFshRAmMvx1RBmyi3ibytyL8CsaNyWCIi laGugnT/LYF/0Pl7oPiDG/tLmrjbIZSaaRqJk+YXDEoF0XuevJQ0h1d56QdiRJyVasRq yH+A== X-Gm-Message-State: ACrzQf3ouYuuK26x/jzFGD9xHeDiUhOpJH4D9qWFoY9YtoBYO8x+62vv pK+uPcSdSGb9NtbFHyKp/IIkbZpvjTEgbw== X-Google-Smtp-Source: AMsMyM7fT5UaVjN3p7q8CeI1AtoJNirnOMJOBwp4lJwfjzep2efuCnyM0Zt0HFzq/xhEe/G8yUblow== X-Received: by 2002:a5d:59a7:0:b0:230:3652:1aa with SMTP id p7-20020a5d59a7000000b00230365201aamr25826300wrr.308.1666716016571; Tue, 25 Oct 2022 09:40:16 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/30] target/arm: Implement FEAT_HAFDBS, access flag portion Date: Tue, 25 Oct 2022 17:39:40 +0100 Message-Id: <20221025163952.4131046-19-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666717000578100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Perform the atomic update for hardware management of the access flag. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20221024051851.3074715-13-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- docs/system/arm/emulation.rst | 1 + target/arm/cpu64.c | 1 + target/arm/ptw.c | 176 +++++++++++++++++++++++++++++----- 3 files changed, 156 insertions(+), 22 deletions(-) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index fd61360a086..e3af79bb8c9 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -33,6 +33,7 @@ the following architecture extensions: - FEAT_FlagM (Flag manipulation instructions v2) - FEAT_FlagM2 (Enhancements to flag manipulation instructions) - FEAT_GTG (Guest translation granule size) +- FEAT_HAFDBS (Hardware management of the access flag and dirty bit state) - FEAT_HCX (Support for the HCRX_EL2 register) - FEAT_HPDS (Hierarchical permission disables) - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index da95eabab5e..f2c3e41f5a7 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1165,6 +1165,7 @@ static void aarch64_max_initfn(Object *obj) cpu->isar.id_aa64mmfr0 =3D t; =20 t =3D cpu->isar.id_aa64mmfr1; + t =3D FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 1); /* FEAT_HAFDBS, AF onl= y */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ t =3D FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 73b3c37b23f..03776f47a01 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -21,7 +21,9 @@ typedef struct S1Translate { bool in_secure; bool in_debug; bool out_secure; + bool out_rw; bool out_be; + hwaddr out_virt; hwaddr out_phys; void *out_host; } S1Translate; @@ -219,6 +221,8 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, uint8_t pte_attrs; bool pte_secure; =20 + ptw->out_virt =3D addr; + if (unlikely(ptw->in_debug)) { /* * From gdbstub, do not use softmmu so that we don't modify the @@ -247,6 +251,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, pte_secure =3D is_secure; } ptw->out_host =3D NULL; + ptw->out_rw =3D false; } else { CPUTLBEntryFull *full; int flags; @@ -261,6 +266,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Transl= ate *ptw, goto fail; } ptw->out_phys =3D full->phys_addr; + ptw->out_rw =3D full->prot & PROT_WRITE; pte_attrs =3D full->pte_attrs; pte_secure =3D full->attrs.secure; } @@ -304,14 +310,16 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Trans= late *ptw, ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); + void *host =3D ptw->out_host; uint32_t data; =20 - if (likely(ptw->out_host)) { + if (likely(host)) { /* Page tables are in RAM, and we have the host address. */ + data =3D qatomic_read((uint32_t *)host); if (ptw->out_be) { - data =3D ldl_be_p(ptw->out_host); + data =3D be32_to_cpu(data); } else { - data =3D ldl_le_p(ptw->out_host); + data =3D le32_to_cpu(data); } } else { /* Page tables are in MMIO. */ @@ -337,15 +345,25 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Trans= late *ptw, ARMMMUFaultInfo *fi) { CPUState *cs =3D env_cpu(env); + void *host =3D ptw->out_host; uint64_t data; =20 - if (likely(ptw->out_host)) { + if (likely(host)) { /* Page tables are in RAM, and we have the host address. */ +#ifdef CONFIG_ATOMIC64 + data =3D qatomic_read__nocheck((uint64_t *)host); if (ptw->out_be) { - data =3D ldq_be_p(ptw->out_host); + data =3D be64_to_cpu(data); } else { - data =3D ldq_le_p(ptw->out_host); + data =3D le64_to_cpu(data); } +#else + if (ptw->out_be) { + data =3D ldq_be_p(host); + } else { + data =3D ldq_le_p(host); + } +#endif } else { /* Page tables are in MMIO. */ MemTxAttrs attrs =3D { .secure =3D ptw->out_secure }; @@ -366,6 +384,91 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Transl= ate *ptw, return data; } =20 +static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val, + uint64_t new_val, S1Translate *ptw, + ARMMMUFaultInfo *fi) +{ + uint64_t cur_val; + void *host =3D ptw->out_host; + + if (unlikely(!host)) { + fi->type =3D ARMFault_UnsuppAtomicUpdate; + fi->s1ptw =3D true; + return 0; + } + + /* + * Raising a stage2 Protection fault for an atomic update to a read-on= ly + * page is delayed until it is certain that there is a change to make. + */ + if (unlikely(!ptw->out_rw)) { + int flags; + void *discard; + + env->tlb_fi =3D fi; + flags =3D probe_access_flags(env, ptw->out_virt, MMU_DATA_STORE, + arm_to_core_mmu_idx(ptw->in_ptw_idx), + true, &discard, 0); + env->tlb_fi =3D NULL; + + if (unlikely(flags & TLB_INVALID_MASK)) { + assert(fi->type !=3D ARMFault_None); + fi->s2addr =3D ptw->out_virt; + fi->stage2 =3D true; + fi->s1ptw =3D true; + fi->s1ns =3D !ptw->in_secure; + return 0; + } + + /* In case CAS mismatches and we loop, remember writability. */ + ptw->out_rw =3D true; + } + +#ifdef CONFIG_ATOMIC64 + if (ptw->out_be) { + old_val =3D cpu_to_be64(old_val); + new_val =3D cpu_to_be64(new_val); + cur_val =3D qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, ne= w_val); + cur_val =3D be64_to_cpu(cur_val); + } else { + old_val =3D cpu_to_le64(old_val); + new_val =3D cpu_to_le64(new_val); + cur_val =3D qatomic_cmpxchg__nocheck((uint64_t *)host, old_val, ne= w_val); + cur_val =3D le64_to_cpu(cur_val); + } +#else + /* + * We can't support the full 64-bit atomic cmpxchg on the host. + * Because this is only used for FEAT_HAFDBS, which is only for AA64, + * we know that TCG_OVERSIZED_GUEST is set, which means that we are + * running in round-robin mode and could only race with dma i/o. + */ +#ifndef TCG_OVERSIZED_GUEST +# error "Unexpected configuration" +#endif + bool locked =3D qemu_mutex_iothread_locked(); + if (!locked) { + qemu_mutex_lock_iothread(); + } + if (ptw->out_be) { + cur_val =3D ldq_be_p(host); + if (cur_val =3D=3D old_val) { + stq_be_p(host, new_val); + } + } else { + cur_val =3D ldq_le_p(host); + if (cur_val =3D=3D old_val) { + stq_le_p(host, new_val); + } + } + if (!locked) { + qemu_mutex_unlock_iothread(); + } +#endif + + return cur_val; +} + static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, uint32_t *table, uint32_t address) { @@ -1058,7 +1161,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, uint32_t el =3D regime_el(env, mmu_idx); uint64_t descaddrmask; bool aarch64 =3D arm_el_is_aa64(env, el); - uint64_t descriptor; + uint64_t descriptor, new_descriptor; bool nstable; =20 /* TODO: This code does not support shareability levels. */ @@ -1272,7 +1375,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Tr= anslate *ptw, if (fi->type !=3D ARMFault_None) { goto do_fault; } + new_descriptor =3D descriptor; =20 + restart_atomic_update: if (!(descriptor & 1) || (!(descriptor & 2) && (level =3D=3D 3))) { /* Invalid, or the Reserved level 3 encoding */ goto do_translation_fault; @@ -1318,17 +1423,36 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, * to give a correct page or table address, the address field * in a block descriptor is smaller; so we need to explicitly * clear the lower bits here before ORing in the low vaddr bits. + * + * Afterward, descaddr is the final physical address. */ page_size =3D (1ULL << ((stride * (4 - level)) + 3)); descaddr &=3D ~(hwaddr)(page_size - 1); descaddr |=3D (address & (page_size - 1)); =20 + if (likely(!ptw->in_debug)) { + /* + * Access flag. + * If HA is enabled, prepare to update the descriptor below. + * Otherwise, pass the access fault on to software. + */ + if (!(descriptor & (1 << 10))) { + if (param.ha) { + new_descriptor |=3D 1 << 10; /* AF */ + } else { + fi->type =3D ARMFault_AccessFlag; + goto do_fault; + } + } + } + /* - * Extract attributes from the descriptor, and apply table descriptors. - * Stage 2 table descriptors do not include any attribute fields. - * HPD disables all the table attributes except NSTable. + * Extract attributes from the (modified) descriptor, and apply + * table descriptors. Stage 2 table descriptors do not include + * any attribute fields. HPD disables all the table attributes + * except NSTable. */ - attrs =3D descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 1= 4)); + attrs =3D new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(5= 0, 14)); if (!regime_is_stage2(mmu_idx)) { attrs |=3D nstable << 5; /* NS */ if (!param.hpd) { @@ -1342,18 +1466,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, } } =20 - /* - * Here descaddr is the final physical address, and attributes - * are all in attrs. - */ - if ((attrs & (1 << 10)) =3D=3D 0) { - /* Access flag */ - fi->type =3D ARMFault_AccessFlag; - goto do_fault; - } - ap =3D extract32(attrs, 6, 2); - if (regime_is_stage2(mmu_idx)) { ns =3D mmu_idx =3D=3D ARMMMUIdx_Stage2; xn =3D extract64(attrs, 53, 2); @@ -1370,6 +1483,25 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, goto do_fault; } =20 + /* If FEAT_HAFDBS has made changes, update the PTE. */ + if (new_descriptor !=3D descriptor) { + new_descriptor =3D arm_casq_ptw(env, descriptor, new_descriptor, p= tw, fi); + if (fi->type !=3D ARMFault_None) { + goto do_fault; + } + /* + * I_YZSVV says that if the in-memory descriptor has changed, + * then we must use the information in that new value + * (which might include a different output address, different + * attributes, or generate a fault). + * Restart the handling of the descriptor value from scratch. + */ + if (new_descriptor !=3D descriptor) { + descriptor =3D new_descriptor; + goto restart_atomic_update; + } + } + if (ns) { /* * The NS bit will (as required by the architecture) have no effec= t if --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666717290; cv=none; d=zohomail.com; s=zohoarc; b=RzYKsxjGKGkZJdnW6VysPDLpGoah0ZVUh7Fr81T/G9zlv8r78acNVQQvBTZji1YC7Ge393WwhwInZFx60p14bnge4INIqVInjFOb7cqHvlOpvmLjDbDrpbg/f3UEvcy21zrrgrrmQYimQE4N9U9CSApdWx6ut+TI4JyjP5yZk34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666717290; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5W0kVIix3U3mXWnUq0kB/Q/Vahrm6fZkJGySoHAD2KY=; b=jVSDSUKv1l0xSRPCC15c86d8oWpY21AfxCtdEbvtjoWyRtekPL/v/ybKMX67lnP76yBmcgPP1Owhcp7KE1Rkea9ldG20uRwpdsdeG6pu5DwGqJrnB73qp7AIUxabwn9oJlD+0XiTdsNqYXMDJcL7UJCM97vNHXNH7YEdJ6BiBi4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666717290501760.7969996466275; Tue, 25 Oct 2022 10:01:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMyt-0006ak-C7; Tue, 25 Oct 2022 12:40:48 -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 1onMyg-0006Ct-2L for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:34 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyR-0001eh-Tg for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:27 -0400 Received: by mail-wr1-x433.google.com with SMTP id j15so11554328wrq.3 for ; Tue, 25 Oct 2022 09:40:18 -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.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:17 -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=5W0kVIix3U3mXWnUq0kB/Q/Vahrm6fZkJGySoHAD2KY=; b=UUZIdy+NtnEd7MIaUHhgXh7UiCNrX5WM21dlowj33+sbzTpEzGyqyXMyNtl6ezXQTl 6VZ7rX20JcjB335EaNV7LsEgXHp0YvDuKHmpRYfBRk0pHgAmDQreMGQ1HxV6e3UGrZhy PIF4zU3aqbgEOq+eZXsoru0yYR8aND1P/kzwWjXfW0MkJQJmyigpW6QlHoESiqRYNzhp Lx1Lp8ju8Oh06qiCPaz+JPbIxcQ1WEBCtvaryMQEiuOMlFfdao8iTgmoi0CCERfK8UER F6HUkQChnr9Mz06i4IpmXOQLBAH2zQLvFYjGv3JZMxR7VIg2kXlX5RvlBOEqQhulwWQZ bGuw== 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=5W0kVIix3U3mXWnUq0kB/Q/Vahrm6fZkJGySoHAD2KY=; b=M1Eo+gSnzOL0lMzjpdAEWmBVBasTFb5jxY9i95SiYTPgLlGbF6gwNn+osLnoawiYBb ygWmJjN0q+rBl93runFHqFrz3w0kZ/i/wsBtYTyCKWtR5A/aXKjQ9ccq5lfRCoa5jHa1 sxNJSNBsCSO3RnZ/Llz51U4ueS4gUHFjrJ1jYfqCp8Juwohwrkmn87+K+YxMnew7XYrH sOhaHD/wd+HkYGIcqbzpl4rPYZlDvHhwpRwVyaUyYniqukM4AHWsYXW6dW7TyV0koqUd u1l2MHFFSTtetIRAKNNOi2AnNNEnKAkWy6w60F0L/yKRi0wEPcKkO+/zYSguN5TtkjZv MV5w== X-Gm-Message-State: ACrzQf1yOV+opWoG4I4sF3Ekgvgg+GR6POrZA/cB2unMgKYQXfyKg3tA BAfbn1qvmAmz2MGHbsGtA1gdMeH1Q/OFPQ== X-Google-Smtp-Source: AMsMyM6Ih+eBPllpCwyVe58+V/hBZbGc62t8jeDWT994oartzbbkN7i9E+mV4PCR8NYLNemh7CApxw== X-Received: by 2002:a05:6000:1565:b0:22f:1407:9bfd with SMTP id 5-20020a056000156500b0022f14079bfdmr25689116wrz.620.1666716017619; Tue, 25 Oct 2022 09:40:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/30] target/arm: Implement FEAT_HAFDBS, dirty bit portion Date: Tue, 25 Oct 2022 17:39:41 +0100 Message-Id: <20221025163952.4131046-20-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666717292613100003 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Perform the atomic update for hardware management of the dirty bit. Signed-off-by: Richard Henderson Message-id: 20221024051851.3074715-14-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu64.c | 2 +- target/arm/ptw.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index f2c3e41f5a7..3d74f134f57 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1165,7 +1165,7 @@ static void aarch64_max_initfn(Object *obj) cpu->isar.id_aa64mmfr0 =3D t; =20 t =3D cpu->isar.id_aa64mmfr1; - t =3D FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 1); /* FEAT_HAFDBS, AF onl= y */ + t =3D FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ t =3D FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 03776f47a01..6b8f14fb3cd 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1444,6 +1444,22 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1T= ranslate *ptw, goto do_fault; } } + + /* + * Dirty Bit. + * If HD is enabled, pre-emptively set/clear the appropriate AP/S2= AP + * bit for writeback. The actual write protection test may still be + * overridden by tableattrs, to be merged below. + */ + if (param.hd + && extract64(descriptor, 51, 1) /* DBM */ + && access_type =3D=3D MMU_DATA_STORE) { + if (regime_is_stage2(mmu_idx)) { + new_descriptor |=3D 1ull << 7; /* set S2AP[1] */ + } else { + new_descriptor &=3D ~(1ull << 7); /* clear AP[2] */ + } + } } =20 /* --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716656; cv=none; d=zohomail.com; s=zohoarc; b=TUAGyQmnTgFqGW1GTSuRiheCq0AcWWsrEB2RPPkNMAhDHxrDqMr4DcefTcoFJOYD6V1LFcDbqnXenh2caLz0mCJJAMuMoi7YzchAXUdqEEj0x2BfBmheXEYhAXxlzHEXJwUk5RYIPkbosFGaAQKoKWNLNyWZX73Tk4k23NgXSz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716656; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YF2gaOVZ8h4GLrNXErHddIokoruQLmVA620L7O1U4TA=; b=XOdzXldfkkkoEP3MBMhBkh2OW9w7EcEG/odUd4SMrR9ysi5WdLvN+w0Favcp3WI2DMFTJSe0N+v57pl5SG6+EdY63fzsytksDtazgVpGLoBpKWahN7Wq34ZeWhL2A53MCocAOOAKV6J2iSjbfNK7yV9N9Tni2eR+n/VFaM+0LPw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166671665634429.178799221521103; Tue, 25 Oct 2022 09:50:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzg-0007Xb-PP; Tue, 25 Oct 2022 12:41:36 -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-0006eO-AW for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:55 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyf-0001mo-Lc for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:49 -0400 Received: by mail-wr1-x432.google.com with SMTP id bk15so22062367wrb.13 for ; Tue, 25 Oct 2022 09:40:30 -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.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:18 -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=YF2gaOVZ8h4GLrNXErHddIokoruQLmVA620L7O1U4TA=; b=yrkClq3wbvHIDB2sAwvpOEyJiZkWYXjJOxnRJvaKmvhTiyyOVxzYIVRE2MNy34HmRR lmPS4M2Ks0mJ9quG7qlhpOceH2d5FekGHZv/MV1EF2JhrYXcuUOKeeJ5u+nfVzQp9eDt bvLaI25If/NYcW8hdH/XlsMeA0dw2s2Y5d+ZXnF6TImFFWSciupDCKfMVu297BbrPUeY 14Z/wPS3WSz/Hg6BLlto7CyoSfjl/jegVuRws3ZIEwaj+atjhL4k5XYXVrl/tnHzfAds oZbMiZ+jOKKtzt8WVxjg/7UO1DJa4jWqluLK++lUjaYx0POMq5nkIqyByZgwtkb5BQS7 DFyA== 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=YF2gaOVZ8h4GLrNXErHddIokoruQLmVA620L7O1U4TA=; b=NpxBqTuF6k8mOTRJjk3nOF1YdehwC5tboBG43wSghRFMDlHmEr3dxh3mrwTemrb1Eb G+0psfQU7PBSYQN8WSnxng4kG6tJ1y/MLeqRZMwge/2bK3peKAK78ghHkLGIGJSRA+aQ bxsqo9U2xo/3ZHTFJBsvrOqZb9LwlEgNN8Xwr5y3bnpDhWLjxs4LtbblArWn02Vj8Dcv E3R7qNNNNL17pHBS4BsOc58b4iDS7SrdF0YvmO6faaLf6WNDUd2Vlrh/eFifJe8/z2fX 40Mv98n5+GkVMGk5RSLMruRC1CjPjYa2LZss+OuH0Zo5hxwm6MUli9EhL0VSSdaMBZaM jkAA== X-Gm-Message-State: ACrzQf2TbfAI9T3FqdERjo1HBd0k7549uxTCaDoMuWmMQYYSKIl9x6ts L/EIty/27nyPxwP+2T4I+qOBx3s8un8Sjw== X-Google-Smtp-Source: AMsMyM5ZfO3DqASvra/96L330P4jReb3E3DZyx0coV2gYXTuUyb9EyCs72ibIfB7/s0ZcAaYKWjgTA== X-Received: by 2002:a05:6000:1548:b0:22e:3469:b726 with SMTP id 8-20020a056000154800b0022e3469b726mr25788021wry.10.1666716018542; Tue, 25 Oct 2022 09:40:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/30] target/arm: Use the max page size in a 2-stage ptw Date: Tue, 25 Oct 2022 17:39:42 +0100 Message-Id: <20221025163952.4131046-21-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716656662100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson We had only been reporting the stage2 page size. This causes problems if stage1 is using a larger page size (16k, 2M, etc), but stage2 is using a smaller page size, because cputlb does not set large_page_{addr,mask} properly. Fix by using the max of the two page sizes. Reported-by: Marc Zyngier Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20221024051851.3074715-15-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 6b8f14fb3cd..23b1f1e6598 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2570,7 +2570,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, ARMMMUFaultInfo *fi) { hwaddr ipa; - int s1_prot; + int s1_prot, s1_lgpgsz; bool is_secure =3D ptw->in_secure; bool ret, ipa_secure, s2walk_secure; ARMCacheAttrs cacheattrs1; @@ -2606,6 +2606,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, = S1Translate *ptw, * Save the stage1 results so that we may merge prot and cacheattrs la= ter. */ s1_prot =3D result->f.prot; + s1_lgpgsz =3D result->f.lg_page_size; cacheattrs1 =3D result->cacheattrs; memset(result, 0, sizeof(*result)); =20 @@ -2620,6 +2621,14 @@ static bool get_phys_addr_twostage(CPUARMState *env,= S1Translate *ptw, return ret; } =20 + /* + * Use the maximum of the S1 & S2 page size, so that invalidation + * of pages > TARGET_PAGE_SIZE works correctly. + */ + if (result->f.lg_page_size < s1_lgpgsz) { + result->f.lg_page_size =3D s1_lgpgsz; + } + /* Combine the S1 and S2 cache attributes. */ hcr =3D arm_hcr_el2_eff_secstate(env, is_secure); if (hcr & HCR_DC) { --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666717149; cv=none; d=zohomail.com; s=zohoarc; b=aLWEKxkW2ybDTrKRrtemXAznFKVgADJX2S9y/udU8PmsLqmp9nX8XxSPdUnn8QNTBYoQtSvB7mmAK3d6Pl1DXMtepjDRiSkMHF34PXLArSPd0QpMcrNc2l1XNp2UCyIFcAuoc7E0Zp1LCksXbKlE1xvWVzg3Hm2QEBSLadnwlpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666717149; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dHUGzacVw5sdIuMhwKh9xLJWJQ68t/gsEeLTMKidbqg=; b=S0EJZBEoJHS1wBwWnEpAr2DBf5fajNP7f4nlbZVllyMDuDO2Gj6/cGOWQAm1bP/aePRLnNTtQr43i8tzXc9ybmf0L9dzlzt0fGTdKuwqcGWh2uDswjOL/ZM0GpICXRhBU04wBoTxQ24IKRrylfH8I/12NE5CIOBRm/uDaLq6pg8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16667171493322.0549309311167008; Tue, 25 Oct 2022 09:59:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMz6-0006n0-To; Tue, 25 Oct 2022 12:41:00 -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 1onMyt-0006al-HM for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:51 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMya-0001bS-Bo for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:47 -0400 Received: by mail-wr1-x42d.google.com with SMTP id a14so19285849wru.5 for ; Tue, 25 Oct 2022 09:40:20 -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.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:19 -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=dHUGzacVw5sdIuMhwKh9xLJWJQ68t/gsEeLTMKidbqg=; b=bE12J3Wsj3falnPtKRbFo6XTBswa2KsNcISsWYw8V9IyBx/oquhf+IFPoDwFcA59Bd uAVHu1tr4zkD8rao9jZsVYK7bGCnwlwFnBvhP00TAl+MwGi0NGpa9LW09V1uDjaB+npA oeVsHS88AdCoHkCuMzyjVr2KQ089wiLHerLB7OpuFmtDnBrsLpfma1lpZEAlDv0vuP5F jWw9pVO5s2A+J1W8Lz3e9ghu6dHUgPc5ws0I9N9eSROzpX88QGi3/AQCuW36gZxGMeOo uPO7HgTsAi9yrFnkhhlm84eKiY4XoYIrg5QrjXqLB6HFiBECUxgfq4L4wi8iNzpM77JZ P7Vw== 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=dHUGzacVw5sdIuMhwKh9xLJWJQ68t/gsEeLTMKidbqg=; b=L85hv9YDekQvZXsV+NBROqtzb65M24yjSGy4OPzdqKeWW0wR/t7yCgtzW5r9VIv63/ +1jrp7Q4QnuPNhVNIw9gQp6/xmAEGMVaEOnoSyyKlZMsYfp8k9dRCtCQLTz7NAcNpO/l Rskx0FIHbV0ShxIzj9s0kw6RfRKGQJmXfR2uoOLHa3vC/IbhLp3QZe04K3xWGXQz8AC7 jMR1FivrUg4zezbF/zzX/nG+9vUUbC3B+GDJFSSeSJDDDKcYbOQQRJ7wJPH6SndgVz/l gtB044gKrgBE8vfMD4sq4LUZ/JzaQv0wXWVMELD9ChEm2yXbxmlbvbeFBFXKt/Dsbxin RuSg== X-Gm-Message-State: ACrzQf26bdp6Y3e+UmzdMThLbcoi704S24qHFPYfZR0eElMUPvE/ghrv JXrR06Vbx4UR1pw2SctSjw2IFeoCiWtI4Q== X-Google-Smtp-Source: AMsMyM60PxsBT+jxPjJZOVRPBFFefm/S8GFr0o2hysBLH+ZcTrZICqbo9jQ3nSDdoEgLX0cy0DVnNA== X-Received: by 2002:a05:6000:170a:b0:22e:bd9c:2630 with SMTP id n10-20020a056000170a00b0022ebd9c2630mr26894645wrc.655.1666716019744; Tue, 25 Oct 2022 09:40:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/30] reset: allow registering handlers that aren't called by snapshot loading Date: Tue, 25 Oct 2022 17:39:43 +0100 Message-Id: <20221025163952.4131046-22-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666717151577100001 Content-Type: text/plain; charset="utf-8" From: "Jason A. Donenfeld" Snapshot loading only expects to call deterministic handlers, not non-deterministic ones. So introduce a way of registering handlers that won't be called when reseting for snapshots. Signed-off-by: Jason A. Donenfeld Message-id: 20221025004327.568476-2-Jason@zx2c4.com [PMM: updated json doc comment with Markus' text; fixed checkpatch style nit] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- qapi/run-state.json | 6 +++++- include/hw/boards.h | 2 +- include/sysemu/reset.h | 5 ++++- hw/arm/aspeed.c | 4 ++-- hw/arm/mps2-tz.c | 4 ++-- hw/core/reset.c | 17 ++++++++++++++++- hw/hppa/machine.c | 4 ++-- hw/i386/microvm.c | 4 ++-- hw/i386/pc.c | 6 +++--- hw/ppc/pegasos2.c | 4 ++-- hw/ppc/pnv.c | 4 ++-- hw/ppc/spapr.c | 4 ++-- hw/s390x/s390-virtio-ccw.c | 4 ++-- migration/savevm.c | 2 +- softmmu/runstate.c | 11 ++++++++--- 15 files changed, 54 insertions(+), 27 deletions(-) diff --git a/qapi/run-state.json b/qapi/run-state.json index 49989d30e6b..419c188dd1a 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -86,12 +86,16 @@ # ignores --no-reboot. This is useful for sanitizing # hypercalls on s390 that are used during kexec/kdump/bo= ot # +# @snapshot-load: A snapshot is being loaded by the record & replay +# subsystem. This value is used only within QEMU. It +# doesn't occur in QMP. (since 7.2) +# ## { 'enum': 'ShutdownCause', # Beware, shutdown_caused_by_guest() depends on enumeration order 'data': [ 'none', 'host-error', 'host-qmp-quit', 'host-qmp-system-reset', 'host-signal', 'host-ui', 'guest-shutdown', 'guest-reset', - 'guest-panic', 'subsystem-reset'] } + 'guest-panic', 'subsystem-reset', 'snapshot-load'] } =20 ## # @StatusInfo: diff --git a/include/hw/boards.h b/include/hw/boards.h index 311ed17e18c..90f1dd3aeb7 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -231,7 +231,7 @@ struct MachineClass { const char *deprecation_reason; =20 void (*init)(MachineState *state); - void (*reset)(MachineState *state); + void (*reset)(MachineState *state, ShutdownCause reason); void (*wakeup)(MachineState *state); int (*kvm_type)(MachineState *machine, const char *arg); =20 diff --git a/include/sysemu/reset.h b/include/sysemu/reset.h index 0b0d6d7598c..609e4d50c26 100644 --- a/include/sysemu/reset.h +++ b/include/sysemu/reset.h @@ -1,10 +1,13 @@ #ifndef QEMU_SYSEMU_RESET_H #define QEMU_SYSEMU_RESET_H =20 +#include "qapi/qapi-events-run-state.h" + typedef void QEMUResetHandler(void *opaque); =20 void qemu_register_reset(QEMUResetHandler *func, void *opaque); +void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaq= ue); void qemu_unregister_reset(QEMUResetHandler *func, void *opaque); -void qemu_devices_reset(void); +void qemu_devices_reset(ShutdownCause reason); =20 #endif diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index bc3ecdb6199..69cadb1c37c 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -1349,12 +1349,12 @@ static void aspeed_machine_bletchley_class_init(Obj= ectClass *oc, void *data) aspeed_soc_num_cpus(amc->soc_name); } =20 -static void fby35_reset(MachineState *state) +static void fby35_reset(MachineState *state, ShutdownCause reason) { AspeedMachineState *bmc =3D ASPEED_MACHINE(state); AspeedGPIOState *gpio =3D &bmc->soc.gpio; =20 - qemu_devices_reset(); + qemu_devices_reset(reason); =20 /* Board ID: 7 (Class-1, 4 slots) */ object_property_set_bool(OBJECT(gpio), "gpioV4", true, &error_fatal); diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c index 394192b9b20..284c09c91d3 100644 --- a/hw/arm/mps2-tz.c +++ b/hw/arm/mps2-tz.c @@ -1239,7 +1239,7 @@ static void mps2_set_remap(Object *obj, const char *v= alue, Error **errp) } } =20 -static void mps2_machine_reset(MachineState *machine) +static void mps2_machine_reset(MachineState *machine, ShutdownCause reason) { MPS2TZMachineState *mms =3D MPS2TZ_MACHINE(machine); =20 @@ -1249,7 +1249,7 @@ static void mps2_machine_reset(MachineState *machine) * reset see the correct mapping. */ remap_memory(mms, mms->remap); - qemu_devices_reset(); + qemu_devices_reset(reason); } =20 static void mps2tz_class_init(ObjectClass *oc, void *data) diff --git a/hw/core/reset.c b/hw/core/reset.c index 36be82c491a..d3263b613e6 100644 --- a/hw/core/reset.c +++ b/hw/core/reset.c @@ -33,6 +33,7 @@ typedef struct QEMUResetEntry { QTAILQ_ENTRY(QEMUResetEntry) entry; QEMUResetHandler *func; void *opaque; + bool skip_on_snapshot_load; } QEMUResetEntry; =20 static QTAILQ_HEAD(, QEMUResetEntry) reset_handlers =3D @@ -47,6 +48,16 @@ void qemu_register_reset(QEMUResetHandler *func, void *o= paque) QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); } =20 +void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaq= ue) +{ + QEMUResetEntry *re =3D g_new0(QEMUResetEntry, 1); + + re->func =3D func; + re->opaque =3D opaque; + re->skip_on_snapshot_load =3D true; + QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); +} + void qemu_unregister_reset(QEMUResetHandler *func, void *opaque) { QEMUResetEntry *re; @@ -60,12 +71,16 @@ void qemu_unregister_reset(QEMUResetHandler *func, void= *opaque) } } =20 -void qemu_devices_reset(void) +void qemu_devices_reset(ShutdownCause reason) { QEMUResetEntry *re, *nre; =20 /* reset all devices */ QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) { + if (reason =3D=3D SHUTDOWN_CAUSE_SNAPSHOT_LOAD && + re->skip_on_snapshot_load) { + continue; + } re->func(re->opaque); } } diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index e53d5f0fa74..19ea7c2c663 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -411,12 +411,12 @@ static void machine_hppa_init(MachineState *machine) cpu[0]->env.gr[19] =3D FW_CFG_IO_BASE; } =20 -static void hppa_machine_reset(MachineState *ms) +static void hppa_machine_reset(MachineState *ms, ShutdownCause reason) { unsigned int smp_cpus =3D ms->smp.cpus; int i; =20 - qemu_devices_reset(); + qemu_devices_reset(reason); =20 /* Start all CPUs at the firmware entry point. * Monarch CPU will initialize firmware, secondary CPUs diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 52f9aa9d8cc..ffd18841007 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -467,7 +467,7 @@ static void microvm_machine_state_init(MachineState *ma= chine) microvm_devices_init(mms); } =20 -static void microvm_machine_reset(MachineState *machine) +static void microvm_machine_reset(MachineState *machine, ShutdownCause rea= son) { MicrovmMachineState *mms =3D MICROVM_MACHINE(machine); CPUState *cs; @@ -480,7 +480,7 @@ static void microvm_machine_reset(MachineState *machine) mms->kernel_cmdline_fixed =3D true; } =20 - qemu_devices_reset(); + qemu_devices_reset(reason); =20 CPU_FOREACH(cs) { cpu =3D X86_CPU(cs); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 768982ae9a0..3e86083db31 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1847,12 +1847,12 @@ static void pc_machine_initfn(Object *obj) cxl_machine_init(obj, &pcms->cxl_devices_state); } =20 -static void pc_machine_reset(MachineState *machine) +static void pc_machine_reset(MachineState *machine, ShutdownCause reason) { CPUState *cs; X86CPU *cpu; =20 - qemu_devices_reset(); + qemu_devices_reset(reason); =20 /* Reset APIC after devices have been reset to cancel * any changes that qemu_devices_reset() might have done. @@ -1867,7 +1867,7 @@ static void pc_machine_reset(MachineState *machine) static void pc_machine_wakeup(MachineState *machine) { cpu_synchronize_all_states(); - pc_machine_reset(machine); + pc_machine_reset(machine, SHUTDOWN_CAUSE_NONE); cpu_synchronize_all_post_reset(); } =20 diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index ecf682b1482..bb4d008ba94 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -248,14 +248,14 @@ static void pegasos2_pci_config_write(Pegasos2Machine= State *pm, int bus, pegasos2_mv_reg_write(pm, pcicfg + 4, len, val); } =20 -static void pegasos2_machine_reset(MachineState *machine) +static void pegasos2_machine_reset(MachineState *machine, ShutdownCause re= ason) { Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); void *fdt; uint64_t d[2]; int sz; =20 - qemu_devices_reset(); + qemu_devices_reset(reason); if (!pm->vof) { return; /* Firmware should set up machine so nothing to do */ } diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 40bb573d1ac..3d01e26f845 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -643,13 +643,13 @@ static void pnv_powerdown_notify(Notifier *n, void *o= paque) } } =20 -static void pnv_reset(MachineState *machine) +static void pnv_reset(MachineState *machine, ShutdownCause reason) { PnvMachineState *pnv =3D PNV_MACHINE(machine); IPMIBmc *bmc; void *fdt; =20 - qemu_devices_reset(); + qemu_devices_reset(reason); =20 /* * The machine should provide by default an internal BMC simulator. diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f79ac85ca1f..66b414d2e9b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1623,7 +1623,7 @@ void spapr_check_mmu_mode(bool guest_radix) } } =20 -static void spapr_machine_reset(MachineState *machine) +static void spapr_machine_reset(MachineState *machine, ShutdownCause reaso= n) { SpaprMachineState *spapr =3D SPAPR_MACHINE(machine); PowerPCCPU *first_ppc_cpu; @@ -1649,7 +1649,7 @@ static void spapr_machine_reset(MachineState *machine) spapr_setup_hpt(spapr); } =20 - qemu_devices_reset(); + qemu_devices_reset(reason); =20 spapr_ovec_cleanup(spapr->ov5_cas); spapr->ov5_cas =3D spapr_ovec_new(); diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 03855c72318..8017acb1d51 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -405,7 +405,7 @@ static void s390_pv_prepare_reset(S390CcwMachineState *= ms) s390_pv_prep_reset(); } =20 -static void s390_machine_reset(MachineState *machine) +static void s390_machine_reset(MachineState *machine, ShutdownCause reason) { S390CcwMachineState *ms =3D S390_CCW_MACHINE(machine); enum s390_reset reset_type; @@ -427,7 +427,7 @@ static void s390_machine_reset(MachineState *machine) s390_machine_unprotect(ms); } =20 - qemu_devices_reset(); + qemu_devices_reset(reason); s390_crypto_reset(); =20 /* configure and start the ipl CPU only */ diff --git a/migration/savevm.c b/migration/savevm.c index 48e85c052c2..a0cdb714f74 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3058,7 +3058,7 @@ bool load_snapshot(const char *name, const char *vmst= ate, goto err_drain; } =20 - qemu_system_reset(SHUTDOWN_CAUSE_NONE); + qemu_system_reset(SHUTDOWN_CAUSE_SNAPSHOT_LOAD); mis->from_src_file =3D f; =20 if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) { diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 1e68680b9d7..3dd83d5e5d8 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -441,11 +441,16 @@ void qemu_system_reset(ShutdownCause reason) cpu_synchronize_all_states(); =20 if (mc && mc->reset) { - mc->reset(current_machine); + mc->reset(current_machine, reason); } else { - qemu_devices_reset(); + qemu_devices_reset(reason); } - if (reason && reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { + switch (reason) { + case SHUTDOWN_CAUSE_NONE: + case SHUTDOWN_CAUSE_SUBSYSTEM_RESET: + case SHUTDOWN_CAUSE_SNAPSHOT_LOAD: + break; + default: qapi_event_send_reset(shutdown_caused_by_guest(reason), reason); } cpu_synchronize_all_post_reset(); --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716567; cv=none; d=zohomail.com; s=zohoarc; b=FpAQ+2uoBOHZ1ZRC+6xb5BpVXEvRQd9UanNFzdIbuaORJtU/HkM32JgfXFIYOx/hZOBx+hkFdQVxNDKuXSUB8oz8tvrwbAQ14Qrh1zTJTYjVZVobpZNritWUhr1MKFFPXex50unZd4kS06JFg6aqYosDCQUffofa7zXckWv/EtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716567; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iSSkQIh++VAD6z3sAniBXAoaqSqq2v9dCC5ucK7zVik=; b=cWRhw0XJ7n/5NWNB5KCjtbU2cB56Z/wDWLt5vl1PdNPR/ZE6rIxRbQHgWyDE21GWpxR6NWj4YNCs9XIarFtIBQvcUHgCH6/N4CNQzQKLMyalRKNhXrlSVRBStYFJy/+Dx4Y8KXf+TPoFeDdkCpejoqH+Ieo1AkZNvP+BkMS+C68= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716567937879.7207242308792; Tue, 25 Oct 2022 09:49:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzf-0007WY-WD; Tue, 25 Oct 2022 12:41:36 -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-0006e7-A4 for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:55 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyf-0001iS-IK for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:48 -0400 Received: by mail-wr1-x432.google.com with SMTP id h9so10988009wrt.0 for ; Tue, 25 Oct 2022 09:40:21 -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.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:20 -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=iSSkQIh++VAD6z3sAniBXAoaqSqq2v9dCC5ucK7zVik=; b=WY2UWz9Ui/HSu4rOGVPKPZ7zaygWHXpXns0P/KqqYCudZjvgGWNCI81ugQe9HtAb1/ 7oKsB7IGrN4aKC+C7QeEkc7CGVuY9e7Nkkc96R1xHCMD7Bs9lPOtPWW0fMY2aBX3pLnp dDcDQ2QwNjbnUGH+kND5XqzEF12m76/At/2DsA9+t6T17xX+S3YmTeK+i3UTCP1xo3GG 9Lzk1C+CG2F/UXcLLRAOEA1+S4wYEwHUGNX7agOig4oAOcuYIc1uo2aKudDDik+tOp/i BLocyur9e1RYyDYyNsg61lSzjZXkUklTBg2ZWUvJw40ljQ/lZFePnIv0evYASl7lWa+7 OJpg== 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=iSSkQIh++VAD6z3sAniBXAoaqSqq2v9dCC5ucK7zVik=; b=RlsoQsCL9OeqKgWb0At5HZ3ClOjrGejGHVcPB/+BWjLmKkn/jFiFRjyzVz6gDmKnh3 QmzJOClmIfZnhP6neO3HlOHJSptIA5YZkGlva2brviw3fUs1pE6pnMUO3RhLM1OsUlTi GP7IcJKGCassd8t4vlrR550L/NlbM1KXhpjEDZ0jhK3UZTNnwmFkXMypWhCKR7zR8ILT jmNILuKQE5tGHZahCUyJNfi3+AGWQOWBOJix1nQ1kFrNbbw+pCKPefVCCCXpeyyAzGdg /DKN6XIcvEp1dw3KsoFcKnX5BF8spTbB2SkpwGoLoLsvZ0ALSB2wTND+SlCLk2om6zNt UnmQ== X-Gm-Message-State: ACrzQf1XDkXGrsz3OWvJQC8hSJSUI4s04hqyG9wBmkh3Z0r2HZobujX4 QE6YdcG8S9RHIBl1A9ZKmSPZd9+Dc8jNIA== X-Google-Smtp-Source: AMsMyM4I8PQxPGtwwv7+oh91TwU2ISIZjVWT2L3Cb2TE58HDX5gChAC0N2Lxt4T5CIYc3qL7oWrc6g== X-Received: by 2002:a05:6000:1887:b0:236:7b1a:b14c with SMTP id a7-20020a056000188700b002367b1ab14cmr4648162wri.173.1666716020725; Tue, 25 Oct 2022 09:40:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/30] device-tree: add re-randomization helper function Date: Tue, 25 Oct 2022 17:39:44 +0100 Message-Id: <20221025163952.4131046-23-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716568237100001 Content-Type: text/plain; charset="utf-8" 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. Several architectures require this functionality, so export a function for injecting a new seed into the given FDT. Cc: Alistair Francis Cc: David Gibson Signed-off-by: Jason A. Donenfeld Reviewed-by: Alistair Francis Message-id: 20221025004327.568476-3-Jason@zx2c4.com Signed-off-by: Peter Maydell --- include/sysemu/device_tree.h | 9 +++++++++ softmmu/device_tree.c | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index e7c5441f564..ca5339beae8 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -197,6 +197,15 @@ int qemu_fdt_setprop_sized_cells_from_array(void *fdt, qdt_tmp); \ }) =20 + +/** + * qemu_fdt_randomize_seeds: + * @fdt: device tree blob + * + * Re-randomize all "rng-seed" properties with new seeds. + */ +void qemu_fdt_randomize_seeds(void *fdt); + #define FDT_PCI_RANGE_RELOCATABLE 0x80000000 #define FDT_PCI_RANGE_PREFETCHABLE 0x40000000 #define FDT_PCI_RANGE_ALIASED 0x20000000 diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index ce74f3d48d7..30aa3aea9fa 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -22,6 +22,7 @@ #include "qemu/option.h" #include "qemu/bswap.h" #include "qemu/cutils.h" +#include "qemu/guest-random.h" #include "sysemu/device_tree.h" #include "hw/loader.h" #include "hw/boards.h" @@ -680,3 +681,23 @@ void hmp_dumpdtb(Monitor *mon, const QDict *qdict) =20 info_report("dtb dumped to %s", filename); } + +void qemu_fdt_randomize_seeds(void *fdt) +{ + int noffset, poffset, len; + const char *name; + uint8_t *data; + + for (noffset =3D fdt_next_node(fdt, 0, NULL); + noffset >=3D 0; + noffset =3D fdt_next_node(fdt, noffset, NULL)) { + for (poffset =3D fdt_first_property_offset(fdt, noffset); + poffset >=3D 0; + poffset =3D fdt_next_property_offset(fdt, poffset)) { + data =3D (uint8_t *)fdt_getprop_by_offset(fdt, poffset, &name,= &len); + if (!data || strcmp(name, "rng-seed")) + continue; + qemu_guest_getrandom_nofail(data, len); + } + } +} --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716136; cv=none; d=zohomail.com; s=zohoarc; b=PBdJpM0bF8DE3omFFclVmYNQssIF5VxYpHsYlq6hRL5ZgKloO+103vfCt2CRZ+ZJ+ynlUrHtKVLw8EUS2GFEarZxM7Cx2nz0FxO5zRLs/Wr3U3IAL2gnEr6R+j0i5ZrQnZfi3aE4aSXa5heAQsImLEerAGXFQoUVgO9WlBVF3sg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716136; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BI6oZ4aEIYwnI+ESyvZ1YC+hWtdkqyODG5DEJQCOMTc=; b=aPKpaXaarYi0YaaStymIcyPlyZoPqd+g667M17UW5/RkOJ+NajdbtwsqnFaAY85nluBaKWKJBNUf+cCKWgjp98R9LG6ZOI0aRBSQ+vk+Zr4mhB3rInRKtHdqRIKOhNhk9zHeOZsvYOQDZUn4jPcThaIkfMe0W8biEvjOt3ekzeY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716136686130.1924654309105; Tue, 25 Oct 2022 09:42:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzT-00070f-74; Tue, 25 Oct 2022 12:41:23 -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-0006du-6u for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:55 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyf-0001kD-LB for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:49 -0400 Received: by mail-wm1-x32d.google.com with SMTP id c7-20020a05600c0ac700b003c6cad86f38so11880412wmr.2 for ; Tue, 25 Oct 2022 09:40:22 -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.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:21 -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=BI6oZ4aEIYwnI+ESyvZ1YC+hWtdkqyODG5DEJQCOMTc=; b=EPjhAaD4xvIib8SqVqO4OTkiZkmgTlFKf1dfkAB9sOPWUQpPE+Lt4fvLxoQXhVG86q 2MPQYfoo0gJ2MkIHrf7gQklzOTCJyyqYF3q/4sRe+Gl96e6QCwOS9NSRIWi7BZ9tXf/Y SG+cCbWj70JIVbtwo985Aij83Iq/dZeG8WNc0xJa58s2pFyrOQM5CRYbhGMd8tMjCPO+ RRiS135o439Tk1gfMQD6weW5cSJiNKEXDDPo3W4I4L/Wqgnb4XP7ADMVO/7bykbzy8NF JOpDiSrQgsrtKD3qSmFJ/wPRFz4BIbBZO4g/NOOpuFz9Ns1pnp3BzZQhVGYRCNgOZzJD /s8w== 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=BI6oZ4aEIYwnI+ESyvZ1YC+hWtdkqyODG5DEJQCOMTc=; b=NVxY+/aKxOC73mRyH91zhmqgjAX4knxjowRafcsDwEC9BldLvwUyjhl77r1WqMWF/q 0sQPGHdv5lXdLNxjLRQypKWEfynSYkALESnhl6aOZi8pslN0AOJSH/fJ5TugCgz66i5b DLpNtKEAvgCoXKxF6XDnxkGQfBviai/e2eZsqKDwuCVt36tCc4qrPlmONh2mF1qbRuoJ HIex1OWb3SQ/4J7Mn8ul2oFPOBhW54qq/KTdsr1rrCKpIvgjojKd/NpiCptMoQ5ufRVk 8dUggYgsyfy9wVN729jCP84ycvoyXkDqdfdB6nKnnq3rQyqEXtIyXjlaJ/ZAv9/2H7ZT PuRw== X-Gm-Message-State: ACrzQf0ToV//5NXWUI/gcWARp1/iFsNAKoY9zqy3r3gE5gGd8DqM5Obd IjplYuMGhbtm83v7wwaCbRj+Gps3iMwpvA== X-Google-Smtp-Source: AMsMyM7HFiEpGoYbnslLvJ2+k7t5c/zGP+TVQ9pB4vlTArWR494P/o1syYk5bK3v7HQC317k7EUTng== X-Received: by 2002:a05:600c:19d1:b0:3c7:b52:3aa4 with SMTP id u17-20020a05600c19d100b003c70b523aa4mr20646607wmq.56.1666716021916; Tue, 25 Oct 2022 09:40:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/30] x86: do not re-randomize RNG seed on snapshot load Date: Tue, 25 Oct 2022 17:39:45 +0100 Message-Id: <20221025163952.4131046-24-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716137206100001 Content-Type: text/plain; charset="utf-8" From: "Jason A. Donenfeld" Snapshot loading is supposed to be deterministic, so we shouldn't re-randomize the various seeds used. Signed-off-by: Jason A. Donenfeld Message-id: 20221025004327.568476-4-Jason@zx2c4.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/i386/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 1148f70c03d..bd50a064a36 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -1111,7 +1111,7 @@ void x86_load_linux(X86MachineState *x86ms, setup_data->type =3D cpu_to_le32(SETUP_RNG_SEED); setup_data->len =3D cpu_to_le32(RNG_SEED_LENGTH); qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH); - qemu_register_reset(reset_rng_seed, setup_data); + qemu_register_reset_nosnapshotload(reset_rng_seed, setup_data); fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_KERNEL_DATA, reset_rng_se= ed, NULL, setup_data, kernel, kernel_size, true); } else { --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716548; cv=none; d=zohomail.com; s=zohoarc; b=bC/Adq8Cmwh7TxG5BZVSlVPS3ORw7Bl9sebIVw7fLPjYtP7vJIUdwBY2Bm5UgfaOW/CNZ2yk1TGJrZ5XtB2MURvqkTD7u4k/tDbYBKdBmhKDjjQIihXVHQJjq9eQCEafUapPYaHMzxL9PoJfLkXqeSE/WFYa0vaj7zum4YYeyV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716548; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Eln4ge06npuUpSMBwWAzr3VNU4hXMayNTGSGJ/gD114=; b=E8WhalEGDa7z8d6dQrUONVcyPgFJqnx1mu4dTemoIj6lfMC3LpgpJhSQZL346HlIuWTHr/QNIbnQRH0yl7zo21cR9O/Qq6z/KO93N+g8sYiLQfjKkL+nJIuXtW1Kp5vJRDAo5zugP2INLQEFo/z3wLiDeTtyX3UJA9562kJ2vlg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716548129497.4196623008082; Tue, 25 Oct 2022 09:49:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzf-0007Ua-9l; Tue, 25 Oct 2022 12:41:35 -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-0006e0-7n for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:55 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyf-0001km-LL for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:50 -0400 Received: by mail-wr1-x432.google.com with SMTP id bs21so6188375wrb.4 for ; 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:22 -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=Eln4ge06npuUpSMBwWAzr3VNU4hXMayNTGSGJ/gD114=; b=BI0z7qfQhZWPTltWMDsSY5di33s5cPeKHWgi5xTObpmqyYVM20k/xF6bl26N9oHQOQ R4TvZml04Yp4xNxZUwqma5WyEDbc2NGYm4EWf50R7Z0vXtooNE4tadhsP3KNZwOln1yH ifC784TLE65j2S9Ly32+pD/I2h7Rv1nFpLO818P6kmCmuhy/UEvwo4EaNCEKAIwZOOXT AbMpR089TM+iORgrblHvJNtHpzXQU9pFKM4PzNf0aCHy4q2uHlNa08l07HCyzlJVWl9N 8tZRx1QZHxVrJbSlsplM1YYnn4v4/ViUyeQ4t2CxFTBmw6qxKrB2hI/ViHtuCEgOqfr9 JCxw== 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=Eln4ge06npuUpSMBwWAzr3VNU4hXMayNTGSGJ/gD114=; b=wDkaYtGjSsjCKoR37g4I8TuEhdMPT/4wtvKo7SJGKg84F0NS8h7dLtV4o49P9DOwvu I4RmGKiuOeYNBBvuPAL+fOpI/jOYXBslyPzbqd5DWVIgUSxugQyc7GC8PuvTkKBc13qt R9/Ut1gyULV13xyBkup93okh7fn5lnRHJlEuqqh9hH12mIbgpi1+wK1oFIe+tsuXd4I6 4MLtiGkJU0F3gGSUc0pJcOphQN6lEaeplHxA5OJ5ffWFjmrJ8IGkKqKd9DKypvULAKth ei3sakj5RsYNAgV3w7MVopR5nE8NeOrdT6SnUgvvPzdDr2gPKbGeGGJxBAF9w5llOQ+h F4Tg== X-Gm-Message-State: ACrzQf3Yl8w+XV5iLV0CFRzLDiSlxM2ar/JTjHy4jmgRXsibGmpDM17M k0KbyxPYdIqpuwh3Lwo2HWanWgsha7nPXg== X-Google-Smtp-Source: AMsMyM5H9izKxEgk0SSB8Ktb5G5H5NjZZ5WifwHgm5KjTFibtSrOc9XBOkn3XKl/G+WiRKt4qoprbA== X-Received: by 2002:a05:6000:1143:b0:236:5ede:cdad with SMTP id d3-20020a056000114300b002365edecdadmr12723586wrx.410.1666716022828; Tue, 25 Oct 2022 09:40:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/30] arm: re-randomize rng-seed on reboot Date: Tue, 25 Oct 2022 17:39:46 +0100 Message-Id: <20221025163952.4131046-25-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716550154100011 Content-Type: text/plain; charset="utf-8" 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: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Jason A. Donenfeld Message-id: 20221025004327.568476-5-Jason@zx2c4.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/boot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index b0b92af1889..b106f314685 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -683,6 +683,8 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_inf= o *binfo, * the DTB is copied again upon reset, even if addr points into RAM. */ rom_add_blob_fixed_as("dtb", fdt, size, addr, as); + qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds, + rom_ptr_for_as(as, addr, size)); =20 g_free(fdt); =20 --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666717000; cv=none; d=zohomail.com; s=zohoarc; b=OEwyIwSGgvZNfOUZiw2DK7QBGxGvADaWrF3nz0UvmIKkijXMFaILu2txnXUEoGTvikkr08dc0cm+ye73Y42BPbjfRM49KVaqy7V/BWEsKKhvfxL5dPVemtHzndL0je7MbXlJHIfUmsywDmaNTDN/iowTtQOEU+TA59nwcA5mNWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666717000; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DvesqOhV7EJhBL7AyS6aZECDQXhGGLTgIADuZfEnRis=; b=KK41AL5cq1KKx0Sczxm/TzBHffUxApieOttdR95M14tU4gVzsgZ7QC/tduBKe3x0Z6uHPg3rX+TxGfWUQBy8IFvuBZttItJPGXAJpEOOIt61GhKvnyT+8m2z2NkqP2xQm/Pr2zZjpWPTCsX/RTm3Qq8rfFufGGPrXBKzo7QxJH0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666717000315716.1625387944987; Tue, 25 Oct 2022 09:56:40 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AMsMyM4nI2anJ/BvDHMTCIDc5SlewGMqqg/oOkwJdVBJan4xhwfDE37MeT/i7QwCR+tSQPiNw20txQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666717002437100009 Content-Type: text/plain; charset="utf-8" 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" =20 #include =20 @@ -241,6 +242,8 @@ uint64_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_= size, void *fdt) =20 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, fd= tsize)); =20 return fdt_addr; } --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716230; cv=none; d=zohomail.com; s=zohoarc; b=NnszJ1RDH3M8VMqSZ8JaqqaSiovtPxRBPFP+/Bigg5byw3uHcpPTUdn37yWkO7lwl5XNPA+TcbihzxhXUgbMP2tXPfEqg4RajNU1AdBRJzA9wWKTtJ8tBOymcjFt7yDXAI3A+nLx2eNenPiSIUsnoAWRixkc2suuNYK1d+NHHto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716230; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+Huf0vTV0723KK8XSSSroit5uyfCugRgjfLfrDKUKmw=; b=Xz5YozsV+cAeFrdm0pTjYnaE+8QfDyNa3OB1hoEPBI/RDCxGz/pA2ZRoqgICTBlefEWymlO/lL0QNNAOxjaNmItpGgTbVRpWAJ7Ue8YuUHPd/S/OQW8ZmRt0Rco+VvRx38iFlgsUPm21brvS63pgZTeg40xGYwQuU00ex077CG0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716230794760.8912333723368; Tue, 25 Oct 2022 09:43:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzi-0007Xf-1Z; Tue, 25 Oct 2022 12:41:38 -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 1onMz2-0006hZ-Cn for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:56 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyg-0001lC-Nd for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:50 -0400 Received: by mail-wr1-x42f.google.com with SMTP id bu30so22089775wrb.8 for ; Tue, 25 Oct 2022 09:40:26 -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.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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=+Huf0vTV0723KK8XSSSroit5uyfCugRgjfLfrDKUKmw=; b=HoXm89nUZP0V8/7l1odxIt0Yy0+ky/TyxzEQpyLF2fkBCWYv166yzen4yzQSkzjvxH OP8zsnwh/koOMtbtOpl7OzppHcuShhrw6hzU8JJK//4d/l2TAcOj7tfOQ1yetOlLUV4P ErqsEmnJS7oVgjQtZ4D7lRm4+u9C4Z3u6BPJEe2OVprfcMzgjxFGwqQI07Z53oXq2sTW uuoq1jOqGfzV4PFBaEHmJ0ULvAKIBFv/zhKltcr84fumZCTm9JYhhVddrGZVLPe6a6pD 7V4H2SLEEfBdyZZP5X3cOo4mqbZuCNKHXxg/4jU7P2wBDOOLCXiJ4SiXD0Zj00JUEsfm i2qg== 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=+Huf0vTV0723KK8XSSSroit5uyfCugRgjfLfrDKUKmw=; b=0E22aWJkQ+k95j1Bq/sbk9EGlNOwAkV+83+Lg4eTDi+dbkn3ipIKZNVDHJHC65786d jdVZ8SpMdUKmb6887IycX51HWF8KT0J8uh8DKaAvEJqP3gL6JAlIW1kWLJxZSj5Wm9k2 B7ajjE3Wodzfkdr4FXXgVhvZ3UadkirRQuC3JMNNoZLYGrPWHM1QXy3A/w1BjkfKD8Kt Cmxl1jyaX8F+9VJ4Wsbu8ffgvQy07ex06cP4HfUD5Zv9d1rsZ8+EoKJAGUHfl80PyWjD SBS52x/RTLnkHhCh60i1QufmslheV9lH7nJtSCXqnOc566hqThdASAEUZyBAotIoio2m aKMg== X-Gm-Message-State: ACrzQf3hDfP3WjX2AMIbuteQgjwWjMKr6RheBJ5pLcGZknVwz/6ldk1I o9ob3KbjQTowJYDk4lI9O4kIl92L45aDag== X-Google-Smtp-Source: AMsMyM40tkRFlk3z5df8TwgJivmqfqssnxmoqXcR+jOGnJGMAvmSlpMV51bP25kEg/xXsw3bCUdqyg== X-Received: by 2002:a05:6000:42:b0:236:6c52:bc22 with SMTP id k2-20020a056000004200b002366c52bc22mr9674668wrx.692.1666716024833; Tue, 25 Oct 2022 09:40:24 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/30] m68k/virt: do not re-randomize RNG seed on snapshot load Date: Tue, 25 Oct 2022 17:39:48 +0100 Message-Id: <20221025163952.4131046-27-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716231592100003 Content-Type: text/plain; charset="utf-8" From: "Jason A. Donenfeld" Snapshot loading is supposed to be deterministic, so we shouldn't re-randomize the various seeds used. Signed-off-by: Jason A. Donenfeld Message-id: 20221025004327.568476-7-Jason@zx2c4.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/m68k/virt.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c index 89c4108eb54..da5eafd2756 100644 --- a/hw/m68k/virt.c +++ b/hw/m68k/virt.c @@ -89,7 +89,6 @@ typedef struct { M68kCPU *cpu; hwaddr initial_pc; hwaddr initial_stack; - struct bi_record *rng_seed; } ResetInfo; =20 static void main_cpu_reset(void *opaque) @@ -98,16 +97,18 @@ static void main_cpu_reset(void *opaque) M68kCPU *cpu =3D reset_info->cpu; CPUState *cs =3D CPU(cpu); =20 - if (reset_info->rng_seed) { - qemu_guest_getrandom_nofail((void *)reset_info->rng_seed->data + 2, - be16_to_cpu(*(uint16_t *)reset_info->rng_seed->data)); - } - cpu_reset(cs); cpu->env.aregs[7] =3D reset_info->initial_stack; cpu->env.pc =3D reset_info->initial_pc; } =20 +static void rerandomize_rng_seed(void *opaque) +{ + struct bi_record *rng_seed =3D opaque; + qemu_guest_getrandom_nofail((void *)rng_seed->data + 2, + be16_to_cpu(*(uint16_t *)rng_seed->data)); +} + static void virt_init(MachineState *machine) { M68kCPU *cpu =3D NULL; @@ -289,9 +290,10 @@ static void virt_init(MachineState *machine) BOOTINFO0(param_ptr, BI_LAST); rom_add_blob_fixed_as("bootinfo", param_blob, param_ptr - param_bl= ob, parameters_base, cs->as); - reset_info->rng_seed =3D rom_ptr_for_as(cs->as, parameters_base, - param_ptr - param_blob) + - (param_rng_seed - param_blob); + qemu_register_reset_nosnapshotload(rerandomize_rng_seed, + rom_ptr_for_as(cs->as, parameters_base, + param_ptr - param_blob) + + (param_rng_seed - param_blob)); g_free(param_blob); } } --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716341; cv=none; d=zohomail.com; s=zohoarc; b=hQN2B1uBIcbXGKkdGj1OvAya/5JItdRyrxbqV+M06fybZK9e6PwjilogGUQ7Ztql15HBgzDiYzjakb0+a6xqjxTTOvi45SthcJVkzvbDtzxOWahD079vqV7axSmfkxZFpUC0hWENwx1PpQdEvPIukpHLQRDXnoKe/2a7Z0HCTqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716341; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P4/S2TnBMuR4066WO10l47QBPXMq0WIsweFwKXDKptw=; b=fvOqazR2eU7Se9o2EB1aMzJQLkulYdkzeGtn6Dlx73UJCeltXIcA/f5uGMZElpAWnOlZoJjFuil2vUcfiXJt6lf94AOK1pw6L9nuHVfE4amLzluc5IbcqE53CLAac/1kysrJmnMsp2P9MxJaAi3nqPLGXIA4jmaqCkgedyfijcY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716341056160.30120075277307; Tue, 25 Oct 2022 09:45:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzh-0007Xe-GX; Tue, 25 Oct 2022 12:41:37 -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 1onMz2-0006eg-CE for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:56 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyg-0001lJ-Nm for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:51 -0400 Received: by mail-wr1-x42a.google.com with SMTP id j15so11555003wrq.3 for ; Tue, 25 Oct 2022 09:40:26 -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.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:25 -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=P4/S2TnBMuR4066WO10l47QBPXMq0WIsweFwKXDKptw=; b=ydtjjEuLKaMYSh3N3yZongEp5mNdNTZ6k/z3JROmTbt5Wuce49tgc/oKnYgfgE77bs jYZd1ccbJH9SvhCKHBpAlII8/EtDi//4YmdAIBA7GQikblfY7Y2Loa+obAvFKX0ZMzms PfeaFu/5RKdSz9J5LSU9v6K6phPR3/Nzvp5l91P0yQWCXsvml/8NIhoNMMQUVwQHjI/M YlU0RrX8dwTHvl1bm/MgS14xDbGlUSLTa7MXHpBmqVzfHnkhb6iJC5a/bXXe2DTU2uKk 8LXyBPKsoeVKtEYWOQ27Z+M1e74vC5wcJONjUUS8qu2RnoduWqSYi6f4F0BPz98CdG6X p39A== 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=P4/S2TnBMuR4066WO10l47QBPXMq0WIsweFwKXDKptw=; b=zXYu2QfD3PUGzvuLPvfzy21ywg7xdKInJmxxXn+i5nJX9XqHn6PuvesEhHx58RHROV l2KRs5ZH2l38bbcCb9cPzJpN4tfB4WKnGAdO+CGQfCem2fkUT8YWXVKI4pQEowAG3wfb gq4pxuGCDDKxOALEeAYF+XmKfhf0qHJjKZYzFl8nG2zBm0WKClx/I/7raQSatyWT0feF 8w1yccsrB8LjepAD/dlyZtaNDkmBdyJ9x2F6un9blwH/iOiASiXIXY0kChPZtt1QmC5e N+bZUZmacS9vImic76dlwTGzheikCzf1epdpZV2xgcb4EH4YffErhnN8ISt/W3myzFiG xHxw== X-Gm-Message-State: ACrzQf1kQBrONrvtA4wl0YCPoD1hydvBjVCCx2++G8sGSQc+XRd7uSz0 eLLwjyeBQo0EzyTGl+MPnHRk5iQq3Jj68w== X-Google-Smtp-Source: AMsMyM7ggFBMe6c/l3EHKr2/cqZujnV0PhcUKu79nZ6x1lohf3mhK4+2lc13Y6P11pmlZIgM8vgClg== X-Received: by 2002:adf:e609:0:b0:235:f4e6:c7c1 with SMTP id p9-20020adfe609000000b00235f4e6c7c1mr19595917wrm.217.1666716025788; Tue, 25 Oct 2022 09:40:25 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/30] m68k/q800: do not re-randomize RNG seed on snapshot load Date: Tue, 25 Oct 2022 17:39:49 +0100 Message-Id: <20221025163952.4131046-28-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716342202100003 Content-Type: text/plain; charset="utf-8" From: "Jason A. Donenfeld" Snapshot loading is supposed to be deterministic, so we shouldn't re-randomize the various seeds used. Signed-off-by: Jason A. Donenfeld Message-id: 20221025004327.568476-8-Jason@zx2c4.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/m68k/q800.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index e09e244ddc1..9d52ca66131 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -321,27 +321,23 @@ static const TypeInfo glue_info =3D { }, }; =20 -typedef struct { - M68kCPU *cpu; - struct bi_record *rng_seed; -} ResetInfo; - static void main_cpu_reset(void *opaque) { - ResetInfo *reset_info =3D opaque; - M68kCPU *cpu =3D reset_info->cpu; + M68kCPU *cpu =3D opaque; CPUState *cs =3D CPU(cpu); =20 - if (reset_info->rng_seed) { - qemu_guest_getrandom_nofail((void *)reset_info->rng_seed->data + 2, - be16_to_cpu(*(uint16_t *)reset_info->rng_seed->data)); - } - cpu_reset(cs); cpu->env.aregs[7] =3D ldl_phys(cs->as, 0); cpu->env.pc =3D ldl_phys(cs->as, 4); } =20 +static void rerandomize_rng_seed(void *opaque) +{ + struct bi_record *rng_seed =3D opaque; + qemu_guest_getrandom_nofail((void *)rng_seed->data + 2, + be16_to_cpu(*(uint16_t *)rng_seed->data)); +} + static uint8_t fake_mac_rom[] =3D { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, =20 @@ -397,7 +393,6 @@ static void q800_init(MachineState *machine) NubusBus *nubus; DeviceState *glue; DriveInfo *dinfo; - ResetInfo *reset_info; uint8_t rng_seed[32]; =20 linux_boot =3D (kernel_filename !=3D NULL); @@ -408,12 +403,9 @@ static void q800_init(MachineState *machine) exit(1); } =20 - reset_info =3D g_new0(ResetInfo, 1); - /* init CPUs */ cpu =3D M68K_CPU(cpu_create(machine->cpu_type)); - reset_info->cpu =3D cpu; - qemu_register_reset(main_cpu_reset, reset_info); + qemu_register_reset(main_cpu_reset, cpu); =20 /* RAM */ memory_region_add_subregion(get_system_memory(), 0, machine->ram); @@ -687,9 +679,10 @@ static void q800_init(MachineState *machine) BOOTINFO0(param_ptr, BI_LAST); rom_add_blob_fixed_as("bootinfo", param_blob, param_ptr - param_bl= ob, parameters_base, cs->as); - reset_info->rng_seed =3D rom_ptr_for_as(cs->as, parameters_base, - param_ptr - param_blob) + - (param_rng_seed - param_blob); + qemu_register_reset_nosnapshotload(rerandomize_rng_seed, + rom_ptr_for_as(cs->as, parameters_base, + param_ptr - param_blob) + + (param_rng_seed - param_blob)); g_free(param_blob); } else { uint8_t *ptr; --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716560; cv=none; d=zohomail.com; s=zohoarc; b=gSmD5cOl81iJFDRcQ7DGtlvKoMN6tlQbwJU6RqlcxuN0w0xulB2dF7oFTWtSieMxbqkiZO+zhpl5u3Q61cQkvRG4Zpq8Z/9YUDmqmzyVfiqI9VHZrjXOHluO1amxCcqoBgm0HZlUSA/V1/Xc7iyHw00WswKzWpT7sXdYWY/YkKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716560; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3kQR/k4FXpFM00JdMuTW5fGm+HZ5nsSbJYa2cV1JqRI=; b=NBHZTLBTnN7HhxpUrKTyHMYu6alnpmJTO4c++X6aXih8blCRCiPkOHxdQVfn3OPrtMWM2rA7AXNkZl+QVwOK0g5Qg8Bm2n+9iJFlQMwYtQMm7rmtkWz2klyTVfvu8uDyY/rTSqV0rrA1/w/ONHCNV0WwhX0QkKjzgKUNC1KEcN0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716560454823.3214864119975; Tue, 25 Oct 2022 09:49:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzU-00074C-Kc; Tue, 25 Oct 2022 12:41:24 -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-0006eW-Ae for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:55 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyg-0001bE-OT for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:52 -0400 Received: by mail-wr1-x42a.google.com with SMTP id o4so13850778wrq.6 for ; Tue, 25 Oct 2022 09:40:26 -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.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:26 -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=3kQR/k4FXpFM00JdMuTW5fGm+HZ5nsSbJYa2cV1JqRI=; b=X3RfrRGeIkWpfflrZ0sIMkKcB4wDVLQxAr/iThYJrdWmo35yY66HRL3ap4NpsBHbdP /ci0ikT9tuDf3ODmGZDPpKekrTs4+JJVk1hbJxFyXpM4+ROCqHRYTMTvp7vSHMEBGs6Y blj6pCjBkVjA/X+L12nJvB+jAeKyaWUcgIoC6Tf5ho56ZGyPnI1co8iP+NGCcmMWrxKc NyVu1J8J+NY1CMF+9Ce++DLFlhbVKqBZru8N5jYa3sDxTYNJlP6nXhAvNuGD4NauX4LB VhMxMaluW0pArKIVBLAGjcp7VxynkYMiFZ66xSqGCR+SkTlfU/4E8hd6fwnldHjS6tnk KEMg== 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=3kQR/k4FXpFM00JdMuTW5fGm+HZ5nsSbJYa2cV1JqRI=; b=Nf0VzHy7GNjlwHyAdCJ71MjpdLqPOu/Kty7clsx+aAJ+KmCyWc5KHIKR4aRWRHHNcp mm6JA8VxqY8Gvb5Hm9lquW6DzpjWOqH9nehW065SpyQzyXdEodMD3dlHGJooyHYoKIAq VtnJLEDoiEzo27gl/UDHokb0EE6WXLgrDgEXBSQwTeEx2K/6cIp3Afkkkx/gObFXinaD hz+7B0yCuCiunjCoJ1nBgHLfcVvH9J6nXl7JsaociPu45V7IP9dTeZcpopqV2xyNXS4+ miJbOElioRDatMiqGiOoYK0E0W4hSiu+ril5a4HOtXWQ3nuXyS226rRpO5CCOLP0cOQl Q1jw== X-Gm-Message-State: ACrzQf3fnWDAHjXR7lmThzb/D6Es5yJ3wpKtSjYXO2gPN7XtVLResqW9 2tM1JN4JG2SV7a8h88KOMMa+0rI4Po99Aw== X-Google-Smtp-Source: AMsMyM4hGf3NF9d6G5BB4CR1UpyfsCDVHotZIyYP0owrkaYqHuGGFQW09MU3qx859kfWMqgKcpBt8Q== X-Received: by 2002:a05:6000:156e:b0:22e:6bf3:79d0 with SMTP id 14-20020a056000156e00b0022e6bf379d0mr26621512wrz.456.1666716026739; Tue, 25 Oct 2022 09:40:26 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 28/30] mips/boston: re-randomize rng-seed on reboot Date: Tue, 25 Oct 2022 17:39:50 +0100 Message-Id: <20221025163952.4131046-29-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716562302100003 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: Aleksandar Rikalo Cc: Paul Burton Cc: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason A. Donenfeld Message-id: 20221025004327.568476-9-Jason@zx2c4.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/mips/boston.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index d2ab9da1a01..cab63f43bf4 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -41,6 +41,7 @@ #include "sysemu/sysemu.h" #include "sysemu/qtest.h" #include "sysemu/runstate.h" +#include "sysemu/reset.h" =20 #include #include "qom/object.h" @@ -810,6 +811,8 @@ static void boston_mach_init(MachineState *machine) /* Calculate real fdt size after filter */ dt_size =3D fdt_totalsize(dtb_load_data); rom_add_blob_fixed("dtb", dtb_load_data, dt_size, dtb_paddr); + qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds, + rom_ptr(dtb_paddr, dt_size)); } else { /* Try to load file as FIT */ fit_err =3D load_fit(&boston_fit_loader, machine->kernel_filen= ame, s); --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666717244; cv=none; d=zohomail.com; s=zohoarc; b=Cxg7Cp9M/lNrXKSOTVawKKUPXZN6vh1v53yQVPQYVl1XweFNA4Yl+F+zRMFK4BQKbmAAnaQoD1YWMV+Mn1rwu93Jbdy10+gPbgBpDNbA5/Z+5Qp1SSFXcroAfpZIMb2CelkwJHMSxCWXYd8lOJzw+tBSVLNRFcSgTdHh0yFin6g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666717244; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zx92dKbW4mIOFyLLly74Mf4cM2iwFKImdqM4lHqQOyE=; b=OZ2PmHVb/g9gYuHBROo6XGTmaSh3jBMTwa0VLGJva5awMTO8+keD/N7M51FyOfh35rlGNDUZAliWgAOsGPL/R81xYIe0V7388WDiWgnpc4EN8ERqOuEdBuXRIDMWqp+kjtCwG6WcMbf5v3BVJ0pT5qgkQrIb3AbVr7vqlD0gpRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666717244177980.2969016266516; Tue, 25 Oct 2022 10:00:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMze-0007PG-Eo; Tue, 25 Oct 2022 12:41:34 -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-0006ed-B8 for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:55 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyf-0001mf-M6 for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:53 -0400 Received: by mail-wr1-x42a.google.com with SMTP id bu30so22089995wrb.8 for ; Tue, 25 Oct 2022 09:40:28 -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.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:27 -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=Zx92dKbW4mIOFyLLly74Mf4cM2iwFKImdqM4lHqQOyE=; b=Tr8hiPJ2AX3zJabGsiir7dVeV8v1pYsteXT8GT2b6mjuVTCQ2zv1qYpqtWZIGb8kPS TUsHrGfEDzYYvHkxM2SoZvk7WaTygeV9kQ+vZZjGjEGxu+cqXo+ifYavR9hyGCi6sdQH dcfkfzdCXrAruIUTLneFuEDpog+0SSxFb1HSzVOXzduF+nPO8uNiVYVio97eAi/7hwgh /S+0SR9R+CeboxrkizFhqQIIPx4Dw7QkR6UyQKqK5v502OGkqMMr/80QTfjaIR0sn43t NgU+kz1ktqYYaFOfHJZ+jsgXVPoljOsD02h60n64bKKbuuxnZW9UZ1Ntnrz5Y+QUgCPX 8Gng== 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=Zx92dKbW4mIOFyLLly74Mf4cM2iwFKImdqM4lHqQOyE=; b=aRsiklA38LrsAAM4vi4vbMcK3XfvwcEGC8LjT1JSIxWFfQa/taG1XF83JnKxtNJi0w cZcnfk4w/ckrmK5HwlPpMA1jFCIOZjiPuBO5j1ov0MKccTo/si9CyrmIcWvQsq9bwsum NAij/XJ3sbe0yBtC56RfGtSd1XIjPIZWiFH1x/nTdS99/boDItXHb8P37419g8AC76dm RRzd4JTPEg6mp1EqvYWcbevHIQR3j180q12w3YcBOKpe35Ehj8rfFd8cvH3SpmsPu+69 +06Di9KN3lPhFrCbDDjyLsffclVOnSqAzk6cTyukKV0ptrXYoNVBcFGqV7cKW5N5OvWe rYlw== X-Gm-Message-State: ACrzQf2T6Uv9/Zf+aSYdctvxD1rHOmXW83AUseSBcbdjvVQdK1QvrepI uPnMxpsgqPFtk+baYZpG30FOXsi3ZOLjNg== X-Google-Smtp-Source: AMsMyM6FVdg4u0CudubPQX0O8RmJvxwmS9HhhkdYGOidY5Iaqy1iFT55bzK8Bl4MpCV4sTvBC2+zuA== X-Received: by 2002:a5d:64c7:0:b0:22e:43a6:2801 with SMTP id f7-20020a5d64c7000000b0022e43a62801mr27167355wri.612.1666716027853; Tue, 25 Oct 2022 09:40:27 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 29/30] openrisc: re-randomize rng-seed on reboot Date: Tue, 25 Oct 2022 17:39:51 +0100 Message-Id: <20221025163952.4131046-30-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666717246352100001 Content-Type: text/plain; charset="utf-8" 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: Stafford Horne Signed-off-by: Jason A. Donenfeld Message-id: 20221025004327.568476-11-Jason@zx2c4.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/openrisc/boot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/openrisc/boot.c b/hw/openrisc/boot.c index 128ccbcba24..007e80cd5a0 100644 --- a/hw/openrisc/boot.c +++ b/hw/openrisc/boot.c @@ -14,6 +14,7 @@ #include "hw/openrisc/boot.h" #include "sysemu/device_tree.h" #include "sysemu/qtest.h" +#include "sysemu/reset.h" =20 #include =20 @@ -111,6 +112,8 @@ uint32_t openrisc_load_fdt(void *fdt, hwaddr load_start, =20 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, fd= tsize)); =20 return fdt_addr; } --=20 2.25.1 From nobody Tue May 21 16:35:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666716547; cv=none; d=zohomail.com; s=zohoarc; b=m7bPEqf+tLReTJp5ONtRoMER2gHCE+oQZBBUB/wgdoJAVtpQ+LySmJwYzJvHjoUPia0R5XTDDJM3Vq/09lb2nKHALza2gXQDGT77svv6gwHMtnpd77LqF8v3wIw+A4HDeZob51NgN+/ncq+msZDHzgu+M88Dq8NYiCRONQqdpl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666716547; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EfFP1EGP8gYjL/D4+J6htl9+GvO5ycQd6kECe/O49pA=; b=LGy+OrUMix19DgewCTOY2y35+1cHrtx22CR4PxKEDnxh7eT8CXs/ztpqn3Vp0nOgxD77f8WCEZBzKgnY2qKWOSVrZnHLBOEM4R65I4HfyGzAaF7iUFCX9ZJlpigZZ6Tgit4a5YrO2vrXWtmsbtdSYbDE116f3lSIVAdcnAKRcEg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666716547596539.163108839981; Tue, 25 Oct 2022 09:49:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzc-0007Ej-DC; Tue, 25 Oct 2022 12:41:32 -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-0006eR-Af for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:55 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyf-0001mm-MC for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:49 -0400 Received: by mail-wr1-x435.google.com with SMTP id h9so10988674wrt.0 for ; Tue, 25 Oct 2022 09:40:29 -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.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:28 -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=EfFP1EGP8gYjL/D4+J6htl9+GvO5ycQd6kECe/O49pA=; b=jFwDElESAdGA7Auu2l9zgMmefRi6z/t020oKPU6Vsbvd/ZkMHFiMCZmacD6unIcpHo ENbU9265iMdlQZ3JkCfz6y1QR24z+KmKiTCObsUlooiRuyipIVRBzrwBMKwYIxUzqt17 yYyRbKpUUUw/tpfgOTAJk+IKqgIiHX67gBdHJHZMFHluN/tfHR2gZpR7LWZdVPMKjsev qwi5yy4h3XaXGUh1duxLN9HM5UgTrRevYIEpGeYrM2CMzOyZ0+D4LHe5qJrKQ+vMevDX 5m4DcFZ73daNSFxn7sUDK8TeWwI5c3P18uYlDaeJ95qJHPip3d7SyN/4IH+pcC6GolNb /gLg== 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=EfFP1EGP8gYjL/D4+J6htl9+GvO5ycQd6kECe/O49pA=; b=Zju8tQP/D9Mrfgchi2B7lxEjpvdDDyoy9dCmNaXBcHoYZ5NzcAxy4jZ08VREmsJ7kl bl06+bsZxYUMfkWCr6RWTihClGK4483VvJIcJ4f78YIslyRhkZ2EpxTxy/fZrW6YsgPg 1ksjKmLuWzmxPg1AEJe7UQrJpb/PTWpDHHkgPxQtJ2ulqVzTHUN7uhes7EHd3Z6T0YvZ AxoyaHa3YDrFFB0MdTSk0H9ammAwc/rdraNDHUmEJAhbYvO+8xT0amvyixKkKgz5lj+t MLpv0sIhptc79662ACk5t/uakqQVf75P5F6JHXx0qCY6O2DlF2WzYD7+uYgQEvg+anZL 2gFA== X-Gm-Message-State: ACrzQf1yFgMdD7qUrm1jiLwhiw36wWeZMxV0H9Zggo3qFa/HzUVHNwNI e3ICEVFwxsmyNU0kRNBX26U4NfLRLhwfFw== X-Google-Smtp-Source: AMsMyM7nEnO+eEc3ORjtgjkOjdjCDg4GeT63gTCqwGIbREn5yuBgvrFXxxqxf4xXu7/yqW2pr2aMRg== X-Received: by 2002:a05:6000:1a8e:b0:230:848c:416d with SMTP id f14-20020a0560001a8e00b00230848c416dmr26631550wry.264.1666716029045; Tue, 25 Oct 2022 09:40:29 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 30/30] rx: re-randomize rng-seed on reboot Date: Tue, 25 Oct 2022 17:39:52 +0100 Message-Id: <20221025163952.4131046-31-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666716548192100005 Content-Type: text/plain; charset="utf-8" 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: Yoshinori Sato Signed-off-by: Jason A. Donenfeld Message-id: 20221025004327.568476-12-Jason@zx2c4.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/rx/rx-gdbsim.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c index 8ffe1b8035c..47c17026c73 100644 --- a/hw/rx/rx-gdbsim.c +++ b/hw/rx/rx-gdbsim.c @@ -25,6 +25,7 @@ #include "hw/rx/rx62n.h" #include "sysemu/qtest.h" #include "sysemu/device_tree.h" +#include "sysemu/reset.h" #include "hw/boards.h" #include "qom/object.h" =20 @@ -148,6 +149,8 @@ static void rx_gdbsim_init(MachineState *machine) dtb_offset =3D ROUND_DOWN(machine->ram_size - dtb_size, 16); rom_add_blob_fixed("dtb", dtb, dtb_size, SDRAM_BASE + dtb_offset); + qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds, + rom_ptr(SDRAM_BASE + dtb_offset, dtb_size)= ); /* Set dtb address to R1 */ RX_CPU(first_cpu)->env.regs[1] =3D SDRAM_BASE + dtb_offset; } --=20 2.25.1