From patchwork Mon May 15 09:26:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13241033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49518C77B75 for ; Mon, 15 May 2023 09:27:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyUUF-0004Zu-Kf; Mon, 15 May 2023 05:27: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 1pyUUB-0004XU-Ar; Mon, 15 May 2023 05:27:19 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0: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 1pyUU5-0002r3-Et; Mon, 15 May 2023 05:27:19 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-643557840e4so13550337b3a.2; Mon, 15 May 2023 02:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684142830; x=1686734830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EG+uChkRqLpCa9UFio/Pn/5mI33HfT5FXVHJcPdnIWU=; b=UOm2+naf+zegV0TgIKnARb0WI3mdAGFUtVqmWioWjrKIcGxz7TX2qIiIATQuW1b5iT wlzn4tZWtlkaE92MUEmkww8JgHi4bRRMqEeU3FgsxYao8SbA0XqHCkHSn+7YdEKn/QTb 1nFgWENUfBU/18sPYNCY28oLn6ztsuT4ckGd2erPshw+fPVcVZS5zZsZNg5SZijAi4hf 3SJKtO4kSaxdhAviD9pj8Wue2tDJaAx9c0qIxmxjkhAe9E/TwQ0qzhkj5G92TQrLZ8M3 hADWJ9B50N2ETh+JIw/YP7o5VvQFhS9jqn0HBNjs+RehebQe/gC/IP+5t0HVoWJNckqY 75Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684142830; x=1686734830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EG+uChkRqLpCa9UFio/Pn/5mI33HfT5FXVHJcPdnIWU=; b=MvyovL8sKJ1XPjpWsKSzp/G/hKkmZwsjD23Ed7IrZKkLp+Ngk8hSk5wAT9nQnpinsq Xn0LJysdVRdhnPAyl3NXWGFhZBelmifi4Au8d7hgC2U54sceB01yUqyQTg9kkuSXdVQU Faz055P90Ph3IgjAo87vt8wn5gjC900gYYwnVNbAQ0rg87IMBAvwIjacYEc2+zxNiDiX vgRUGpbqCb0woAW1Jj3jh72eUM2wGWDjGSDMfCV7I2aZctsCtsigz7Vve5l/jfjEEhf5 jxmlnqKZujzXfksrDygUX569z8GOHIi0EDZxlVwR5Q2tfHTl7zC//JWFrYKul6vr9aJB 5bwA== X-Gm-Message-State: AC+VfDwtxSzGBhYP/Wnd6nw/uQduSaV82L5QSvW7fxgpTQ6gPUqcPKza AJVt2+U1WOVCrUedMPggZtT+H/cgLnA= X-Google-Smtp-Source: ACHHUZ7dOEHOooQiE6/TPGORZKLc0iVey8ySsOAPAW9i+9JuK2PiM2b5/HRW+1d42I2nBEzcssFspw== X-Received: by 2002:a05:6a00:a15:b0:647:5409:5d0b with SMTP id p21-20020a056a000a1500b0064754095d0bmr32060584pfh.19.1684142830572; Mon, 15 May 2023 02:27:10 -0700 (PDT) Received: from wheely.local0.net ([202.168.30.146]) by smtp.gmail.com with ESMTPSA id n20-20020aa79054000000b006466f0be263sm11387818pfo.73.2023.05.15.02.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:27:10 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza Subject: [PATCH v3 1/9] target/ppc: Fix width of some 32-bit SPRs Date: Mon, 15 May 2023 19:26:47 +1000 Message-Id: <20230515092655.171206-2-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515092655.171206-1-npiggin@gmail.com> References: <20230515092655.171206-1-npiggin@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=npiggin@gmail.com; helo=mail-pf1-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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Some 32-bit SPRs are incorrectly implemented as 64-bits on 64-bit targets. This changes VRSAVE, DSISR, HDSISR, DAWRX0, PIDR, LPIDR, DEXCR, HDEXCR, CTRL, TSCR, MMCRH, and PMC[1-6] from to be 32-bit registers. This only goes by the 32/64 classification in the architecture, it does not try to implement finer details of SPR implementation (e.g., not all bits implemented as simple read/write storage). Signed-off-by: Nicholas Piggin Reviewed-by: Harsh Prateek Bora --- Since v2: no change. target/ppc/cpu_init.c | 18 +++++++++--------- target/ppc/helper_regs.c | 2 +- target/ppc/misc_helper.c | 4 ++-- target/ppc/power8-pmu.c | 2 +- target/ppc/translate.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 0ce2e3c91d..5aa0b3f0f1 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -5085,8 +5085,8 @@ static void register_book3s_altivec_sprs(CPUPPCState *env) } spr_register_kvm(env, SPR_VRSAVE, "VRSAVE", - &spr_read_generic, &spr_write_generic, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32, + &spr_read_generic, &spr_write_generic32, KVM_REG_PPC_VRSAVE, 0x00000000); } @@ -5120,7 +5120,7 @@ static void register_book3s_207_dbg_sprs(CPUPPCState *env) spr_register_kvm_hv(env, SPR_DAWRX0, "DAWRX0", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32, KVM_REG_PPC_DAWRX, 0x00000000); spr_register_kvm_hv(env, SPR_CIABR, "CIABR", SPR_NOACCESS, SPR_NOACCESS, @@ -5376,7 +5376,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env) spr_register_hv(env, SPR_TSCR, "TSCR", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32, 0x00000000); spr_register_hv(env, SPR_HMER, "HMER", SPR_NOACCESS, SPR_NOACCESS, @@ -5406,7 +5406,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env) spr_register_hv(env, SPR_MMCRC, "MMCRC", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32, 0x00000000); spr_register_hv(env, SPR_MMCRH, "MMCRH", SPR_NOACCESS, SPR_NOACCESS, @@ -5441,7 +5441,7 @@ static void register_book3s_ids_sprs(CPUPPCState *env) spr_register_hv(env, SPR_HDSISR, "HDSISR", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32, 0x00000000); spr_register_hv(env, SPR_HRMOR, "HRMOR", SPR_NOACCESS, SPR_NOACCESS, @@ -5665,7 +5665,7 @@ static void register_power7_book4_sprs(CPUPPCState *env) KVM_REG_PPC_ACOP, 0); spr_register_kvm(env, SPR_BOOKS_PID, "PID", SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32, KVM_REG_PPC_PID, 0); #endif } @@ -5730,7 +5730,7 @@ static void register_power10_dexcr_sprs(CPUPPCState *env) { spr_register(env, SPR_DEXCR, "DEXCR", SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32, 0); spr_register(env, SPR_UDEXCR, "DEXCR", @@ -5741,7 +5741,7 @@ static void register_power10_dexcr_sprs(CPUPPCState *env) spr_register_hv(env, SPR_HDEXCR, "HDEXCR", SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32, 0); spr_register(env, SPR_UHDEXCR, "HDEXCR", diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index 779e7db513..fb351c303f 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -448,7 +448,7 @@ void register_non_embedded_sprs(CPUPPCState *env) /* Exception processing */ spr_register_kvm(env, SPR_DSISR, "DSISR", SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, + &spr_read_generic, &spr_write_generic32, KVM_REG_PPC_DSISR, 0x00000000); spr_register_kvm(env, SPR_DAR, "DAR", SPR_NOACCESS, SPR_NOACCESS, diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index a9bc1522e2..40ddc5c08c 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -190,13 +190,13 @@ void helper_store_dpdes(CPUPPCState *env, target_ulong val) void helper_store_pidr(CPUPPCState *env, target_ulong val) { - env->spr[SPR_BOOKS_PID] = val; + env->spr[SPR_BOOKS_PID] = (uint32_t)val; tlb_flush(env_cpu(env)); } void helper_store_lpidr(CPUPPCState *env, target_ulong val) { - env->spr[SPR_LPIDR] = val; + env->spr[SPR_LPIDR] = (uint32_t)val; /* * We need to flush the TLB on LPID changes as we only tag HV vs diff --git a/target/ppc/power8-pmu.c b/target/ppc/power8-pmu.c index 1381072b9e..64a64865d7 100644 --- a/target/ppc/power8-pmu.c +++ b/target/ppc/power8-pmu.c @@ -272,7 +272,7 @@ void helper_store_pmc(CPUPPCState *env, uint32_t sprn, uint64_t value) { pmu_update_cycles(env); - env->spr[sprn] = value; + env->spr[sprn] = (uint32_t)value; pmc_update_overflow_timer(env, sprn); } diff --git a/target/ppc/translate.c b/target/ppc/translate.c index f603f1a939..c03a6bdc9a 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -413,7 +413,7 @@ void spr_write_generic(DisasContext *ctx, int sprn, int gprn) void spr_write_CTRL(DisasContext *ctx, int sprn, int gprn) { - spr_write_generic(ctx, sprn, gprn); + spr_write_generic32(ctx, sprn, gprn); /* * SPR_CTRL writes must force a new translation block, From patchwork Mon May 15 09:26:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13241037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48F99C7EE22 for ; Mon, 15 May 2023 09:28:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyUUH-0004bY-25; Mon, 15 May 2023 05:27:25 -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 1pyUUC-0004Xq-Gz; Mon, 15 May 2023 05:27:20 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0: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 1pyUU9-0002se-EE; Mon, 15 May 2023 05:27:20 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6436e075166so9319260b3a.0; Mon, 15 May 2023 02:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684142834; x=1686734834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wTWXVkuOJWURPs9/nfkGg41d3eyk1kYbRxT5nVuGrYE=; b=BbZy36pIKf/UKMCUijAbePlVCHl7db3AZ7yzmUw9eUvBUM1QaNsE5w4niQ39+RUKFX v9om2U/SgchV6GIHMsTlrpMrrSVRHUJeoKZHhC+/RjYBsqHHFTwPgaAgCR2aaHW96VbC Pf0S86Ot99asKr/KRWszqqq4ZdH56QNOEzgLzKhXsGjJMF3Zx3VGnO3dcB1MMhRN4p+f KvoYfixv9TCyqV/F84LXhBEjcW7Hsmo4cemXiN3mmCo/P1rzstCLetKv+jZ1rmUzYxoI fckoOr1h+V3Z2a0+b1JEbY4+PNQbab73CFDR2aYAXZThqRbRQ+uH2/0Wiu6HyXlBRE2B azGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684142834; x=1686734834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wTWXVkuOJWURPs9/nfkGg41d3eyk1kYbRxT5nVuGrYE=; b=PwcCF26AV0EfS+Q3QnRzuPWx3FwT4Jv7JFTcEBCh5LZ2BuTIFjNYP/pww7ptJXjdn+ nYbWQusK1oEBJPZxWGOEdYzd5LsfS3Ni76qs/Ly4skJ/80XJaGmjYHx5UTj4SU9nFEsg vswa+1tkAfIuil58nLF4KtqyZ+tLhuHcuUX/Fcn0yR1hpo6zUyK5yWrzDBXNy6VciCtK RvdHT+4Ri4IANIjc6HeLM01mHblNwZkAv/nG4dbLdjzBheKK7jz152z2oowRm+s81C73 KsAFC+tXtu7jfniSWqKM8/PaFvrgjhyAIZwM2mdCtQgi7bxf6HTG+IAiSb4SzAFnZfvv j7wQ== X-Gm-Message-State: AC+VfDxYmXKQz3HWZ2ozn82sWq4PyOa8kt4f5ulwh+masYXPL0OPN981 ub4sFDZGyujSURm+Z2JzEbT3b0wctv0= X-Google-Smtp-Source: ACHHUZ5+fzV8j5Ojo7sI7mdjdz0N1sxddNjcD9BxjSnbKB9NvzBtRQlOZ6FFTbSwCrQA55B+HIXnFA== X-Received: by 2002:a05:6a00:2396:b0:646:6c71:ee13 with SMTP id f22-20020a056a00239600b006466c71ee13mr33070662pfc.24.1684142834050; Mon, 15 May 2023 02:27:14 -0700 (PDT) Received: from wheely.local0.net ([202.168.30.146]) by smtp.gmail.com with ESMTPSA id n20-20020aa79054000000b006466f0be263sm11387818pfo.73.2023.05.15.02.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:27:13 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza Subject: [PATCH v3 2/9] target/ppc: Fix PMU MMCR0[PMCjCE] bit in hflags calculation Date: Mon, 15 May 2023 19:26:48 +1000 Message-Id: <20230515092655.171206-3-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515092655.171206-1-npiggin@gmail.com> References: <20230515092655.171206-1-npiggin@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=npiggin@gmail.com; helo=mail-pf1-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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org A store to MMCR0 with PMCjCE=1 fails to update hflags correctly and results in hflags mismatch: qemu: fatal: TCG hflags mismatch (current:0x2408003d rebuilt:0x240a003d) This can be reproduced by running perf on a recent machine. Signed-off-by: Nicholas Piggin Reviewed-by: Daniel Henrique Barboza --- Since v2: new patch. target/ppc/power8-pmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/ppc/power8-pmu.c b/target/ppc/power8-pmu.c index 64a64865d7..29e0012ed6 100644 --- a/target/ppc/power8-pmu.c +++ b/target/ppc/power8-pmu.c @@ -236,14 +236,16 @@ void helper_store_mmcr0(CPUPPCState *env, target_ulong value) { bool hflags_pmcc0 = (value & MMCR0_PMCC0) != 0; bool hflags_pmcc1 = (value & MMCR0_PMCC1) != 0; + bool hflags_pmcjce = (value & MMCR0_PMCjCE) != 0; pmu_update_cycles(env); env->spr[SPR_POWER_MMCR0] = value; - /* MMCR0 writes can change HFLAGS_PMCC[01] and HFLAGS_INSN_CNT */ + /* MMCR0 writes can change HFLAGS_PMCC[01], PMCjCE, and HFLAGS_INSN_CNT */ env->hflags = deposit32(env->hflags, HFLAGS_PMCC0, 1, hflags_pmcc0); env->hflags = deposit32(env->hflags, HFLAGS_PMCC1, 1, hflags_pmcc1); + env->hflags = deposit32(env->hflags, HFLAGS_PMCJCE, 1, hflags_pmcjce); pmu_update_summaries(env); From patchwork Mon May 15 09:26:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13241038 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 085C7C77B75 for ; Mon, 15 May 2023 09:28:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyUUJ-0004c9-GZ; Mon, 15 May 2023 05:27:27 -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 1pyUUD-0004Yg-D6; Mon, 15 May 2023 05:27:21 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0: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 1pyUUB-0002sy-IW; Mon, 15 May 2023 05:27:21 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-643995a47f7so13012570b3a.1; Mon, 15 May 2023 02:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684142837; x=1686734837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B1gtYriqMp6KeH+Cm1mqAljc/h3SB/6QVeC+84ggT8g=; b=VCZIv8a8d5oDHc/pQzaVy9qqRVxwGI6qTWRHd6uKSpWkzcEjlVyVZjB+cxLWw/ZZld vRuS1bN8aP/mTpHd1NYbmKYzg6K1MClQ5hjK9mlxzhnNZY9jIQ7qsGW2cW2YbETtqxgV WrzNFA58eegN/Y4lvKqP95/VawiQ++kLWkplF/SusQT79yUsU4nrLEGNJ4n8Vx/M4fmK D7QgF0Fxz7B9GvECO6ojgUShqk9omIRA0TOKUPgP6d0NXeQDRllZT42Iphgzh4c7+mA4 kyl+8muN0Qm2+cPGLWypi5MxV1Rc43cjuK0HlYwKLTMP1NjVMs/n039/NYTUxFTaFE7X +KhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684142837; x=1686734837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B1gtYriqMp6KeH+Cm1mqAljc/h3SB/6QVeC+84ggT8g=; b=lqGh36CLqaxnPC3Ty/gK2pmDxwwHaVFHV9kCJlIUVTwp27EXacyQS5zhmYUrXFtXgo Vbg0ETpmMJMA4j+y5Tcvg1z2oVlkWGxNA0DL1IwE2GppECG99I7hToMgwQyT7bnn/2DM MzKcmRqvl3qgtDP3c5SjHenXUYv46W02BZR21l1Fe56u2+2hkT2PFKY4zRpIV8c7eza/ 8XqFrmoe2H6bZV4uGtUsgJzKRwXZZidUVWG29tC492VgH8CljgjtPfv0ulQ1HE6Ft+pm My7Y+WhtRNNasLSv25iNmMiuuZ9+j9WDiKFx8vIL1BXmdWMX4/PAt4Ufe0inL3QhYFp/ 46lw== X-Gm-Message-State: AC+VfDxEb7auPC2vlGNWzKSKrTkfSpse/E+uM9t+2Tr5Ut17Z9jXOIQT 0gVk+pLE11gdA6hFMNiART3sWXdmJD4= X-Google-Smtp-Source: ACHHUZ50E/O+e5Fjwk64EGHCz+vWtqcuJ+qZNYbdzdHyHcTsmHl623fqsq6Hg7DlNiho63gun07Esg== X-Received: by 2002:a05:6a00:a15:b0:647:5409:5d0b with SMTP id p21-20020a056a000a1500b0064754095d0bmr32060903pfh.19.1684142837428; Mon, 15 May 2023 02:27:17 -0700 (PDT) Received: from wheely.local0.net ([202.168.30.146]) by smtp.gmail.com with ESMTPSA id n20-20020aa79054000000b006466f0be263sm11387818pfo.73.2023.05.15.02.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:27:17 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Fabiano Rosas Subject: [PATCH v3 3/9] target/ppc: Fix instruction loading endianness in alignment interrupt Date: Mon, 15 May 2023 19:26:49 +1000 Message-Id: <20230515092655.171206-4-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515092655.171206-1-npiggin@gmail.com> References: <20230515092655.171206-1-npiggin@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=npiggin@gmail.com; helo=mail-pf1-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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org powerpc ifetch endianness depends on MSR[LE] so it has to byteswap after cpu_ldl_code(). This corrects DSISR bits in alignment interrupts when running in little endian mode. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- Since v2: no change. target/ppc/excp_helper.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 199328f4b6..bc2be4a726 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -133,6 +133,24 @@ static void dump_hcall(CPUPPCState *env) env->nip); } +/* Return true iff byteswap is needed in a scalar memop */ +static inline bool need_byteswap(CPUArchState *env) +{ + /* SOFTMMU builds TARGET_BIG_ENDIAN. Need to swap when MSR[LE] is set */ + return !!(env->msr & ((target_ulong)1 << MSR_LE)); +} + +static uint32_t ppc_ldl_code(CPUArchState *env, abi_ptr addr) +{ + uint32_t insn = cpu_ldl_code(env, addr); + + if (need_byteswap(env)) { + insn = bswap32(insn); + } + + return insn; +} + static void ppc_excp_debug_sw_tlb(CPUPPCState *env, int excp) { const char *es; @@ -3097,7 +3115,7 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, /* Restore state and reload the insn we executed, for filling in DSISR. */ cpu_restore_state(cs, retaddr); - insn = cpu_ldl_code(env, env->nip); + insn = ppc_ldl_code(env, env->nip); switch (env->mmu_model) { case POWERPC_MMU_SOFT_4xx: From patchwork Mon May 15 09:26:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13241036 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5C188C77B75 for ; Mon, 15 May 2023 09:28:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyUUL-0004dV-7h; Mon, 15 May 2023 05:27:29 -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 1pyUUG-0004bN-JB; Mon, 15 May 2023 05:27:24 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pyUUF-0002tq-3U; Mon, 15 May 2023 05:27:24 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6434e263962so9179158b3a.2; Mon, 15 May 2023 02:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684142841; x=1686734841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NzoCdEXbfhZ/bRqBlmISivmhbZ7+0QvG20U3xWbXUGU=; b=fHXVS3KPfkp/DgmTuGThMXgwZpMS6Qw/wuVb017kQMOo0Vk9zXgProva58dS1IrD+I ZD3GbVQWwNExXI478qx+793uVAkzNlta4n2B1x+FXRbROkJnSY91ON6xb3nmfSwHUP0i urbki+a2Db6meWsfTHLAY+SlxRe6QWIBjkyFNwc/tlqsj/ZehgLRXGF3PkN4XGYv/Lzs TuaL2sObDSoHghNTHzd4KfGR2S9kgoRb3Oet6pOL16wmEGdUt9P+5ZdDmSu2v//X+Uuh QyHJB9vNTp3b6nRN8Rmu/yfl69L/VpexQDc9oi0HNjuW47XRaQNIJmFvNHA5XuDp1ipk Yzag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684142841; x=1686734841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NzoCdEXbfhZ/bRqBlmISivmhbZ7+0QvG20U3xWbXUGU=; b=fAVak6Dz//mG8gG0t8QGBXgyiEiHlMd1Iq3T08ULNLC7YULOlWg3fJG/CqMJKtv8r8 B61jhzZjbsrLD3FwiQ3fFehFN+4BJoBsq4CAAxcHp1SmGSSsiNimoITAQw/Wgdcxb30I 5y9ktQpVF/AywUMPfESfWJRD7fipSyERl+J/466/otzFGfrEHPmv5f+1awdBXHyQcbM1 MJgdYq2c23+pURGByK3R7FUPQDsoP0yLDNEdE0C3DwMCPyxV9W1eMwpfjDXmoBQGej8h F/JnjaWTcDaSMl9CWDawPmQ7bH/oW1vPn1T1EOASKfHNnsldTAOnKq3O5m4iZQedxYtw 0ycw== X-Gm-Message-State: AC+VfDw9RRTXQITmom4KIIY/W0ED9nB8vbMn9nVBYroGwy1gKGogcADY bVyjX9pgBLopWNXm/wv1isd/fdsMP0o= X-Google-Smtp-Source: ACHHUZ4O3yjpN7I5X9syu4UneYI9JFgcH2Oe0JUGq8U44Erpizq/4sO7q+0ry0jSj/6X5UWQ5Rk1hA== X-Received: by 2002:a05:6a00:2d0e:b0:641:699:f353 with SMTP id fa14-20020a056a002d0e00b006410699f353mr45612894pfb.22.1684142840898; Mon, 15 May 2023 02:27:20 -0700 (PDT) Received: from wheely.local0.net ([202.168.30.146]) by smtp.gmail.com with ESMTPSA id n20-20020aa79054000000b006466f0be263sm11387818pfo.73.2023.05.15.02.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:27:20 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Fabiano Rosas Subject: [PATCH v3 4/9] target/ppc: Alignment faults do not set DSISR in ISA v3.0 onward Date: Mon, 15 May 2023 19:26:50 +1000 Message-Id: <20230515092655.171206-5-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515092655.171206-1-npiggin@gmail.com> References: <20230515092655.171206-1-npiggin@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=npiggin@gmail.com; helo=mail-pf1-x430.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This optional behavior was removed from the ISA in v3.0, see Summary of Changes preface: Data Storage Interrupt Status Register for Alignment Interrupt: Simplifies the Alignment interrupt by remov- ing the Data Storage Interrupt Status Register (DSISR) from the set of registers modified by the Alignment interrupt. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- Since v2: no change. target/ppc/excp_helper.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index bc2be4a726..453750a9d6 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -1449,13 +1449,16 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp) break; } case POWERPC_EXCP_ALIGN: /* Alignment exception */ - /* Get rS/rD and rA from faulting opcode */ - /* - * Note: the opcode fields will not be set properly for a - * direct store load/store, but nobody cares as nobody - * actually uses direct store segments. - */ - env->spr[SPR_DSISR] |= (env->error_code & 0x03FF0000) >> 16; + /* Optional DSISR update was removed from ISA v3.0 */ + if (!(env->insns_flags2 & PPC2_ISA300)) { + /* Get rS/rD and rA from faulting opcode */ + /* + * Note: the opcode fields will not be set properly for a + * direct store load/store, but nobody cares as nobody + * actually uses direct store segments. + */ + env->spr[SPR_DSISR] |= (env->error_code & 0x03FF0000) >> 16; + } break; case POWERPC_EXCP_PROGRAM: /* Program exception */ switch (env->error_code & ~0xF) { From patchwork Mon May 15 09:26:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13241041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 34F80C7EE2E for ; Mon, 15 May 2023 09:29:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyUUM-0004gE-Ek; Mon, 15 May 2023 05:27: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 1pyUUK-0004dG-OL; Mon, 15 May 2023 05:27:28 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pyUUJ-0002uF-4E; Mon, 15 May 2023 05:27:28 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-52c30fbccd4so11524268a12.0; Mon, 15 May 2023 02:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684142844; x=1686734844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zkh/PAEKN8BVQW6YM5l0nufuvJOuPOvJMEVEtv3f5V8=; b=bEkz9Y0N3WFyLWUppWkd8JOyGmGIx038IU4q8XNCuy0/ruXRvTLbB0kCnt6YH4lqL9 84EIhcjoLYe1/xeUJQIj3QuDziJwQ4Tdr45fKcqLdJWIueLK/xr94cdP+A6okvkygDEV NI3xt5FY/jojj0zWM3F/9AbIVHaGZUJhguN1AlNvZoLmDVe6Z1VYgv6Rqr8Iy+jV8lSE vLjPjui4Epoe3Tjz77TMtgFUPu9NFM5M0hEmtc0xhkES5jTjOxVn6/MOOC18/SungyoW vHK3AKHvOFYaMzAemr7w6D8ZOj+v7lpaU1Ykqcc+d5CnBj7qJIsWJV6wO3UASO/7kXrt Zc3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684142844; x=1686734844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zkh/PAEKN8BVQW6YM5l0nufuvJOuPOvJMEVEtv3f5V8=; b=k2P19FPTuYoIEEL7VgXIC9fIhMPeBbjE6NoKoh5asESbdOlXU40iU2fk3eySnLxvwC 3ulUbc5wU+/jByXefnzGbMZshUdZsZDp6XFoVWge54e9/3XgEXKpw5JzmKf5vHd0V8xs H4mzSK08IGm9345uAxD65aqfPqCEhRn9R34RkcLsR0u//Hwk+sH9mMJ1YfPAvPZhNA2B yAxCd7aakvH2lsq+f+zuCmjRUPg5x60DZAtrNuEDiYDMjUvXMNS1DfEg7A120VSSPcU2 UqwQX0q2KaJwn8otXKA1PULaPpneDU/BgS07oZk4MnNmIQfcAZOmhp9XgzZIbzQ4b6O6 gt3w== X-Gm-Message-State: AC+VfDyV8dPreMWUwkXyTu70fgWpm1a3dkbrJoRTqpDcbsFO1czhesuM LgyvMzOnqqqucqopg/itz9jgIAldaDo= X-Google-Smtp-Source: ACHHUZ51v6GiIGvQcgYAIRGwkd5VMaDB46x2nCSEDW0H6rbBR9La6DyEmrDP0+nIGs6t/jWZf/U3Rg== X-Received: by 2002:a05:6a20:549e:b0:100:4369:164a with SMTP id i30-20020a056a20549e00b001004369164amr37714251pzk.46.1684142843875; Mon, 15 May 2023 02:27:23 -0700 (PDT) Received: from wheely.local0.net ([202.168.30.146]) by smtp.gmail.com with ESMTPSA id n20-20020aa79054000000b006466f0be263sm11387818pfo.73.2023.05.15.02.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:27:23 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza Subject: [PATCH v3 5/9] target/ppc: Change partition-scope translate interface Date: Mon, 15 May 2023 19:26:51 +1000 Message-Id: <20230515092655.171206-6-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515092655.171206-1-npiggin@gmail.com> References: <20230515092655.171206-1-npiggin@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=npiggin@gmail.com; helo=mail-pg1-x533.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Rather than always performing partition scope page table translation with access type of 0 (MMU_DATA_LOAD), pass through the processor access type which first initiated the translation sequence. Process- scoped page table loads are then set to MMU_DATA_LOAD access type in the xlate function. This will allow more information to be passed to the exception handler in the next patch. Signed-off-by: Nicholas Piggin --- Since v2: new patch to deal with bug in patch 6. target/ppc/mmu-radix64.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c index 031efda0df..1fc1ba3ecf 100644 --- a/target/ppc/mmu-radix64.c +++ b/target/ppc/mmu-radix64.c @@ -380,6 +380,14 @@ static int ppc_radix64_partition_scoped_xlate(PowerPCCPU *cpu, hwaddr pte_addr; uint64_t pte; + if (pde_addr) { + /* + * Translation of process-scoped tables/directories is performed as + * a read-access. + */ + access_type = MMU_DATA_LOAD; + } + qemu_log_mask(CPU_LOG_MMU, "%s for %s @0x%"VADDR_PRIx " mmu_idx %u 0x%"HWADDR_PRIx"\n", __func__, access_str(access_type), @@ -477,10 +485,10 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu, * is only used to translate the effective addresses of the * process table entries. */ - ret = ppc_radix64_partition_scoped_xlate(cpu, 0, eaddr, prtbe_addr, - pate, &h_raddr, &h_prot, - &h_page_size, true, - /* mmu_idx is 5 because we're translating from hypervisor scope */ + /* mmu_idx is 5 because we're translating from hypervisor scope */ + ret = ppc_radix64_partition_scoped_xlate(cpu, access_type, eaddr, + prtbe_addr, pate, &h_raddr, + &h_prot, &h_page_size, true, 5, guest_visible); if (ret) { return ret; @@ -519,11 +527,11 @@ static int ppc_radix64_process_scoped_xlate(PowerPCCPU *cpu, * translation */ do { - ret = ppc_radix64_partition_scoped_xlate(cpu, 0, eaddr, pte_addr, - pate, &h_raddr, &h_prot, - &h_page_size, true, /* mmu_idx is 5 because we're translating from hypervisor scope */ - 5, guest_visible); + ret = ppc_radix64_partition_scoped_xlate(cpu, access_type, eaddr, + pte_addr, pate, &h_raddr, + &h_prot, &h_page_size, + true, 5, guest_visible); if (ret) { return ret; } From patchwork Mon May 15 09:26:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13241039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 22D27C7EE22 for ; Mon, 15 May 2023 09:29:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyUUp-0004vq-Hl; Mon, 15 May 2023 05:27:59 -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 1pyUUV-0004nX-VN; Mon, 15 May 2023 05:27:40 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0: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 1pyUUL-0002uT-Gz; Mon, 15 May 2023 05:27:39 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6438d95f447so8705572b3a.3; Mon, 15 May 2023 02:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684142847; x=1686734847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eKzTaElM3wY97A0BT54fsna/RWbBlG74gXJr9SNsntU=; b=JyHVtIVib7PHA9WRkO8ArOirZq1LfpySW7Vwq2mwddiLO1eJYp4zxwSYP/5lmkmSBR FZr0E+wLTIcctQ/RMjv5M5Vf+Zygt8KPUJN15UaNpGQo2B2hmHUw9EAX1zNExf1PSU28 HTz3hdrvMi5cs1WYuh2VCKHrgCpYRY/QzRC0VoTQlW1N0yGzubJowMc5BdktLwZvNZ/5 nOF7TM0MXCSxhsX7LkTCjRwnkC801JltR64nlO3kvHX71sgSpzD9Fv1ECtfufXHvOrdq wUaCDoQ+mW39UFAzI62B7ARuUpSNfiMx04ZhaS+xrnUff6xFdkyG8PrV90f/+0w8VYwB NKcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684142847; x=1686734847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eKzTaElM3wY97A0BT54fsna/RWbBlG74gXJr9SNsntU=; b=CGnZIa/O2qZ4yt7qvRzduxHnEr7c9PrKrQdwU0e6DNrEdexEvWsYwp66V5q2Kv1VZu 7X3NC9+yuKTVsDlgWNE1jkw/x9KZHrcirEJbUXf+etYroKcJ7gUKO1s5zel0siy87amf AiDlMwGsp4Iz2Kv2OAW1Kw7dgjII5WMp2yozip/77KSOVa/GbV9zNlrMiW5yqX2JUvUI eR0elG6/LGDWkGe+WAgTRjq3sufudmNUOxBA/NQtdiIi0OZbKs5woTDglRQiOz7MYe1A MKp5t470qyZ4uNuLBB+nEjf3yup3srMBKhYatljgQxiAOZTxbECZD7xEi3Lx7AVOIXOh qqgg== X-Gm-Message-State: AC+VfDztBT1uHptO1IDnUlguE9TCDErfIV01nY8KxFARL2Ed2YQSNR/V pl7v+f+/3PLPnQzLWBWhNH2LI1NNdyA= X-Google-Smtp-Source: ACHHUZ5BZiT9AGMgNqYoue05INZgqmTcHnoFbcmCaScpGl0CaHDb1HzRMnD0jBhF3yb1eXcWQJuJwQ== X-Received: by 2002:a05:6a20:9384:b0:106:93b:aa9a with SMTP id x4-20020a056a20938400b00106093baa9amr3864688pzh.48.1684142847350; Mon, 15 May 2023 02:27:27 -0700 (PDT) Received: from wheely.local0.net ([202.168.30.146]) by smtp.gmail.com with ESMTPSA id n20-20020aa79054000000b006466f0be263sm11387818pfo.73.2023.05.15.02.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:27:26 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Fabiano Rosas Subject: [PATCH v3 6/9] target/ppc: Add SRR1 prefix indication to interrupt handlers Date: Mon, 15 May 2023 19:26:52 +1000 Message-Id: <20230515092655.171206-7-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515092655.171206-1-npiggin@gmail.com> References: <20230515092655.171206-1-npiggin@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=npiggin@gmail.com; helo=mail-pf1-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, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org ISA v3.1 introduced prefix instructions. Among the changes, various synchronous interrupts report whether they were caused by a prefix instruction in (H)SRR1. The case of instruction fetch that causes an HDSI due to access of a process-scoped table faulting on the partition scoped translation is the tricky one. As with ISIs and HISIs, this does not try to set the prefix bit because there is no instruction image to be loaded. The HDSI needs the originating access type to be passed through to the handler to distinguish this from HDSIs that fault translating process scoped tables originating from a load or store instruction (in that case the prefix bit should be provided). Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- Since v2: - Fix a bug where ifetch access causing HDSI due to process scoped table access failing on partition scope translation would go into infinite recursive fault attempting to load the instruction image. This requires more data from the page fault to distinguish this from the same case but initiated by a load or store (in which case we can load the instruction image). target/ppc/excp_helper.c | 44 ++++++++++++++++++++++++++++++++++++++++ target/ppc/mmu-radix64.c | 14 ++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 453750a9d6..27d321c15f 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -1346,12 +1346,21 @@ static bool books_vhyp_handles_hv_excp(PowerPCCPU *cpu) return false; } +static bool is_prefix_excp(CPUPPCState *env, uint32_t insn) +{ + if (!(env->insns_flags2 & PPC2_ISA310)) { + return false; + } + return ((insn & 0xfc000000) == 0x04000000); +} + static void powerpc_excp_books(PowerPCCPU *cpu, int excp) { CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; target_ulong msr, new_msr, vector; int srr0, srr1, lev = -1; + uint32_t insn = 0; /* new srr1 value excluding must-be-zero bits */ msr = env->msr & ~0x783f0000ULL; @@ -1390,6 +1399,41 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp) vector |= env->excp_prefix; + switch (excp) { + case POWERPC_EXCP_HDSI: + /* HDSI PRTABLE_FAULT has the originating access type in error_code */ + if ((env->spr[SPR_HDSISR] & DSISR_PRTABLE_FAULT) && + (env->error_code == MMU_INST_FETCH)) { + /* + * Fetch failed due to partition scope translation, so prefix + * indication is not relevant (and attempting to load the + * instruction at NIP would cause recursive faults with the same + * translation). + */ + break; + } + /* fall through */ + case POWERPC_EXCP_MCHECK: + case POWERPC_EXCP_DSI: + case POWERPC_EXCP_DSEG: + case POWERPC_EXCP_ALIGN: + case POWERPC_EXCP_PROGRAM: + case POWERPC_EXCP_FPU: + case POWERPC_EXCP_TRACE: + case POWERPC_EXCP_HV_EMU: + case POWERPC_EXCP_VPU: + case POWERPC_EXCP_VSXU: + case POWERPC_EXCP_FU: + case POWERPC_EXCP_HV_FU: + insn = ppc_ldl_code(env, env->nip); + if (is_prefix_excp(env, insn)) { + msr |= PPC_BIT(34); + } + break; + default: + break; + } + switch (excp) { case POWERPC_EXCP_MCHECK: /* Machine check exception */ if (!FIELD_EX64(env->msr, MSR, ME)) { diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c index 1fc1ba3ecf..920084bd8f 100644 --- a/target/ppc/mmu-radix64.c +++ b/target/ppc/mmu-radix64.c @@ -145,6 +145,13 @@ static void ppc_radix64_raise_hsi(PowerPCCPU *cpu, MMUAccessType access_type, CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; + env->error_code = 0; + if (cause & DSISR_PRTABLE_FAULT) { + /* HDSI PRTABLE_FAULT gets the originating access type in error_code */ + env->error_code = access_type; + access_type = MMU_DATA_LOAD; + } + qemu_log_mask(CPU_LOG_MMU, "%s for %s @0x%"VADDR_PRIx" 0x%" HWADDR_PRIx" cause %08x\n", __func__, access_str(access_type), @@ -166,7 +173,6 @@ static void ppc_radix64_raise_hsi(PowerPCCPU *cpu, MMUAccessType access_type, env->spr[SPR_HDSISR] = cause; env->spr[SPR_HDAR] = eaddr; env->spr[SPR_ASDR] = g_raddr; - env->error_code = 0; break; default: g_assert_not_reached(); @@ -369,13 +375,14 @@ static bool validate_pate(PowerPCCPU *cpu, uint64_t lpid, ppc_v3_pate_t *pate) } static int ppc_radix64_partition_scoped_xlate(PowerPCCPU *cpu, - MMUAccessType access_type, + MMUAccessType orig_access_type, vaddr eaddr, hwaddr g_raddr, ppc_v3_pate_t pate, hwaddr *h_raddr, int *h_prot, int *h_page_size, bool pde_addr, int mmu_idx, bool guest_visible) { + MMUAccessType access_type = orig_access_type; int fault_cause = 0; hwaddr pte_addr; uint64_t pte; @@ -404,7 +411,8 @@ static int ppc_radix64_partition_scoped_xlate(PowerPCCPU *cpu, fault_cause |= DSISR_PRTABLE_FAULT; } if (guest_visible) { - ppc_radix64_raise_hsi(cpu, access_type, eaddr, g_raddr, fault_cause); + ppc_radix64_raise_hsi(cpu, orig_access_type, + eaddr, g_raddr, fault_cause); } return 1; } From patchwork Mon May 15 09:26:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13241040 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F2DEC7EE26 for ; Mon, 15 May 2023 09:29:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyUUT-0004n0-HK; Mon, 15 May 2023 05:27: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 1pyUUQ-0004it-Nx; Mon, 15 May 2023 05:27:34 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0: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 1pyUUP-0002uw-1M; Mon, 15 May 2023 05:27:34 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-64ac461af60so3714082b3a.3; Mon, 15 May 2023 02:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684142851; x=1686734851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+NbL0Ik4ps0LTyNiuqnemtkETX8V8tJp2mM1329chhs=; b=MEMMmooPupLitljCyBz8zPOAqYZ377JXKiRNE+YxKQUU+jig2oSxY8QYi1N6ZmSHJ4 SzGpfDRid0QdTt+0qhLD+FNjXb8Wr9EPf1/I0BMttNsi4gAzFWIxVmCAcy+GvW6Er4uR 90gF7QNqR6fm7pny7jIY2Oxat1+IxO/3qEnRToF1n6iSuUufC3oPB05b6MXFbbNZC9KI w13YLiyHxTYGxM37mnko1gzvWYB6iDDuMtxJaD89RJOVrcp5QQM9acviDhaWeSlghLxe 8msBAvE3XA6xoEeknj1nn3jvJ5QJWFf/N4w2Emg4MOGb/8+UFiH+rntWlPHwwilSM9EK vy3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684142851; x=1686734851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+NbL0Ik4ps0LTyNiuqnemtkETX8V8tJp2mM1329chhs=; b=AOgmyN/Kj2z1Q/bdodM9UtIMVLtUPE/pdowYnvZX0SCioFjxFdC8NqLyIe56AgZeFK +IZoZbau3umcOHRb0Cs+3RIUOsIajfH/Lt2H8eyjlhkSQpVcttycsYHU+wVZAAZj+lLj kf76RYMesBVSeBwdexaDPL99aBhHxPE+cS0XgV2F0IdsK7y9XDXeykhteFc7qH6q5vrr +19WLiMDAi6um6kWd9ycyCewT5+Il7B7Ufk8NOH7z3ue4nm2k7YFGw5keJ5z+68tCtU3 BMubn+eAnV9FbNdQCTsKofe7IpGwPu6IXN2AwwZS3WYsjtzhpd0WkVbOez69zeiJwKzl dAcg== X-Gm-Message-State: AC+VfDyNS2P4oS8raxu+sfrabfUR+cMAVdv0QS+n+tf5HY82G2T6R8Jf btBNfk3uvm6o2Z0IQRCT6Y+jRiEr1EM= X-Google-Smtp-Source: ACHHUZ7q5I7RHbVgn+AXTI4aG9JCG0epYE2fgdxuIB4nL7nv+8ABXjVSB1vgvUMI7KGnNxJY6ZoeWw== X-Received: by 2002:a05:6a20:2588:b0:103:377e:439e with SMTP id k8-20020a056a20258800b00103377e439emr23671176pzd.60.1684142850823; Mon, 15 May 2023 02:27:30 -0700 (PDT) Received: from wheely.local0.net ([202.168.30.146]) by smtp.gmail.com with ESMTPSA id n20-20020aa79054000000b006466f0be263sm11387818pfo.73.2023.05.15.02.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:27:30 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza , Michael Neuling Subject: [PATCH v3 7/9] target/ppc: Implement HEIR SPR Date: Mon, 15 May 2023 19:26:53 +1000 Message-Id: <20230515092655.171206-8-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515092655.171206-1-npiggin@gmail.com> References: <20230515092655.171206-1-npiggin@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=npiggin@gmail.com; helo=mail-pf1-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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The hypervisor emulation assistance interrupt modifies HEIR to contain the value of the instruction which caused the exception. Signed-off-by: Nicholas Piggin --- Since v2: - Fix ordering of prefix/suffix words in the register, as pointed out by Mikey. target/ppc/cpu.h | 1 + target/ppc/cpu_init.c | 23 +++++++++++++++++++++++ target/ppc/excp_helper.c | 13 ++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 1c02596d9f..73851aa7a3 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1653,6 +1653,7 @@ void ppc_compat_add_property(Object *obj, const char *name, #define SPR_HMER (0x150) #define SPR_HMEER (0x151) #define SPR_PCR (0x152) +#define SPR_HEIR (0x153) #define SPR_BOOKE_LPIDR (0x152) #define SPR_BOOKE_TCR (0x154) #define SPR_BOOKE_TLB0PS (0x158) diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 5aa0b3f0f1..ff73be1812 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -1629,6 +1629,7 @@ static void register_8xx_sprs(CPUPPCState *env) * HSRR0 => SPR 314 (Power 2.04 hypv) * HSRR1 => SPR 315 (Power 2.04 hypv) * LPIDR => SPR 317 (970) + * HEIR => SPR 339 (Power 2.05 hypv) (64-bit reg from 3.1) * EPR => SPR 702 (Power 2.04 emb) * perf => 768-783 (Power 2.04) * perf => 784-799 (Power 2.04) @@ -5522,6 +5523,24 @@ static void register_power6_common_sprs(CPUPPCState *env) 0x00000000); } +static void register_HEIR32_spr(CPUPPCState *env) +{ + spr_register_hv(env, SPR_HEIR, "HEIR", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_generic, &spr_write_generic32, + 0x00000000); +} + +static void register_HEIR64_spr(CPUPPCState *env) +{ + spr_register_hv(env, SPR_HEIR, "HEIR", + SPR_NOACCESS, SPR_NOACCESS, + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_generic, &spr_write_generic, + 0x00000000); +} + static void register_power8_tce_address_control_sprs(CPUPPCState *env) { spr_register_kvm(env, SPR_TAR, "TAR", @@ -5950,6 +5969,7 @@ static void init_proc_POWER7(CPUPPCState *env) register_power5p_ear_sprs(env); register_power5p_tb_sprs(env); register_power6_common_sprs(env); + register_HEIR32_spr(env); register_power6_dbg_sprs(env); register_power7_book4_sprs(env); @@ -6072,6 +6092,7 @@ static void init_proc_POWER8(CPUPPCState *env) register_power5p_ear_sprs(env); register_power5p_tb_sprs(env); register_power6_common_sprs(env); + register_HEIR32_spr(env); register_power6_dbg_sprs(env); register_power8_tce_address_control_sprs(env); register_power8_ids_sprs(env); @@ -6234,6 +6255,7 @@ static void init_proc_POWER9(CPUPPCState *env) register_power5p_ear_sprs(env); register_power5p_tb_sprs(env); register_power6_common_sprs(env); + register_HEIR32_spr(env); register_power6_dbg_sprs(env); register_power8_tce_address_control_sprs(env); register_power8_ids_sprs(env); @@ -6409,6 +6431,7 @@ static void init_proc_POWER10(CPUPPCState *env) register_power5p_ear_sprs(env); register_power5p_tb_sprs(env); register_power6_common_sprs(env); + register_HEIR64_spr(env); register_power6_dbg_sprs(env); register_power8_tce_address_control_sprs(env); register_power8_ids_sprs(env); diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 27d321c15f..529a4513a3 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -1608,13 +1608,24 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp) case POWERPC_EXCP_HDECR: /* Hypervisor decrementer exception */ case POWERPC_EXCP_HDSI: /* Hypervisor data storage exception */ case POWERPC_EXCP_SDOOR_HV: /* Hypervisor Doorbell interrupt */ - case POWERPC_EXCP_HV_EMU: case POWERPC_EXCP_HVIRT: /* Hypervisor virtualization */ srr0 = SPR_HSRR0; srr1 = SPR_HSRR1; new_msr |= (target_ulong)MSR_HVB; new_msr |= env->msr & ((target_ulong)1 << MSR_RI); break; + case POWERPC_EXCP_HV_EMU: + env->spr[SPR_HEIR] = insn; + if (is_prefix_excp(env, insn)) { + uint32_t insn2 = ppc_ldl_code(env, env->nip + 4); + env->spr[SPR_HEIR] <<= 32; + env->spr[SPR_HEIR] |= insn2; + } + srr0 = SPR_HSRR0; + srr1 = SPR_HSRR1; + new_msr |= (target_ulong)MSR_HVB; + new_msr |= env->msr & ((target_ulong)1 << MSR_RI); + break; case POWERPC_EXCP_VPU: /* Vector unavailable exception */ case POWERPC_EXCP_VSXU: /* VSX unavailable exception */ case POWERPC_EXCP_FU: /* Facility unavailable exception */ From patchwork Mon May 15 09:26:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13241042 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 311FFC77B75 for ; Mon, 15 May 2023 09:29:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyUUn-0004pi-5p; Mon, 15 May 2023 05:27:57 -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 1pyUUT-0004n4-Js; Mon, 15 May 2023 05:27:37 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pyUUS-0002vN-5L; Mon, 15 May 2023 05:27:37 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-51b0f9d7d70so11484004a12.1; Mon, 15 May 2023 02:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684142854; x=1686734854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wDS8H8TgM41kNb4ppQTLDBtazoazirTT+YfL2ECPnfQ=; b=mV4BDDTbkbiQRaK3B+fG7N3NcxO5J+OIHeJPsEEMmk9WP7qQIai5QuzyDTztNMO7F3 jFcq94A754tpzdxoDaQ9KUDMKCHbI/IsrSmrq+8rw3SACsh/yWDpIAL8jll53ZjZO1eH MVzqcU8JYqM2bcKFwUke0ejg70zTqTo8KDrfMhwr3JwrZLAQj0C2kwk33hERUXS2Aftw ByzYzBiwbZknALfqu01u3oxIdTJVh3vufxTE1VLlhLcZz1vBJvSRzl6lnk56lr0as5ZC b87D3vou7rcA7bK3L4ktQmGk/heb/zFlVL+u09dNR+ESf29J0FmiWgmOWZ9owMElWHio IwGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684142854; x=1686734854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wDS8H8TgM41kNb4ppQTLDBtazoazirTT+YfL2ECPnfQ=; b=K6VREyzxPaJhX0fn4EWrCikk1dLNZF51gwrY/18L+8Cgr6oIl6veRXOdTniIrambpV Dx65jvysKd33Ni7H1x10I5bbsZO2VWJIvXH2EGcTSq6pZz7TNwpdO/nJEl0xGQvjKBOS +cIgexAGiufukyrohco7T/BcKQ2bEClwn8j+hQQL3/8zFCKYXJ1f845TiWJrMJFvy3Cg fq6AXRL3vDEPA0n9KuZRyvEr8wsoQ3/e8raiuWW6OvOX2V0t73XVCuc18Z7EQCDohTfy /ko4FZW5dsbL+jEmGMwztTNHqDNXGchJnp8JQTosxGkTxJD/rTLJVkxRRWQZOu1MxLhZ 25QQ== X-Gm-Message-State: AC+VfDwmEHUGgRXX2Cb1s0OJqUKF2AngM2OjfvDMt2z9J3Yaidu2eAtF Q65W7EdWqYDCOn+AIdks/3GZSIIy0ho= X-Google-Smtp-Source: ACHHUZ5dHIiZnwbuQMy+PsFvBPopnqbEfAXfgWOcy9xEoSmdNAXNFEIfe8z1nqk4t413EpJXxJW7hQ== X-Received: by 2002:a05:6a20:8f13:b0:101:2160:ff89 with SMTP id b19-20020a056a208f1300b001012160ff89mr29678783pzk.38.1684142853842; Mon, 15 May 2023 02:27:33 -0700 (PDT) Received: from wheely.local0.net ([202.168.30.146]) by smtp.gmail.com with ESMTPSA id n20-20020aa79054000000b006466f0be263sm11387818pfo.73.2023.05.15.02.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:27:33 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza Subject: [PATCH v3 8/9] target/ppc: Add ISA v3.1 LEV indication in SRR1 for system call interrupts Date: Mon, 15 May 2023 19:26:54 +1000 Message-Id: <20230515092655.171206-9-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515092655.171206-1-npiggin@gmail.com> References: <20230515092655.171206-1-npiggin@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=npiggin@gmail.com; helo=mail-pg1-x534.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org System call interrupts in ISA v3.1 CPUs add a LEV indication in SRR1 that corresponds with the LEV field of the instruction that caused the interrupt. Signed-off-by: Nicholas Piggin --- Since v2: new patch. target/ppc/excp_helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 529a4513a3..25f9fa9d3f 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -1559,6 +1559,10 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int excp) vhc->hypercall(cpu->vhyp, cpu); return; } + if (env->insns_flags2 & PPC2_ISA310) { + /* ISAv3.1 puts LEV into SRR1 */ + msr |= lev << 20; + } if (lev == 1) { new_msr |= (target_ulong)MSR_HVB; } From patchwork Mon May 15 09:26:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 13241034 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8102DC77B75 for ; Mon, 15 May 2023 09:28:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyUUq-0004vN-Ek; Mon, 15 May 2023 05:28: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 1pyUUX-0004oO-L5; Mon, 15 May 2023 05:27:44 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0: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 1pyUUU-0002uw-63; Mon, 15 May 2023 05:27:41 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-64ac461af60so3714176b3a.3; Mon, 15 May 2023 02:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684142857; x=1686734857; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SnRhhqxfvd+SIcWbTi+j8dH4u+CPe/avjjrMPZ0jf08=; b=PC7IRPBalQUDTfIyoV6w9HWlBKntMihi/g7kcs855YoZPUs4ekjg3n/0gv9wy39uNC StFaNfg2FKQMA8ntJigYvCMa68fPv7/c5GTTsKeXZqMNK94TP4AES65KauoKO/Pvxn3i WsCLqikmKGvCH/UcUd7n2zWtgq/Bf6iAmXaxV5LBFUMbwId7GdpeeWhzMNq/MT5UHOsB 7bcPiS0F6WR4U1Qk59V0WGbeMi8IMv/Y1vtJbuuMx2J+qjTu/uAUo/cMABuvP9Q+hwh6 L3nb0n/g1Yp6RqRpU65l97xANKI3lD7msX5XtJWH1hMBHnEYAOqDh1/5zpngFwoN2ZoD Ibpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684142857; x=1686734857; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SnRhhqxfvd+SIcWbTi+j8dH4u+CPe/avjjrMPZ0jf08=; b=kvSXH3U6DTivc8R2dzxsjdl2Y+JikvEdvsszjwH2CykkMCWr6PNOZIKFfH/7oRAW14 Iag0k8JcyvU96Uo8vKsWdy0tMKTlMyrTRvcc4kKH1OYl9wf1/lTbwXeo1y8B7Nt7o7lO x1sdvz/USMF/FrCZS8xXlXOMYrNwdWMJitAJhzWh15RR1HpEj/fc9S8ilk3HkW85CuxN ZQHjkyANfiXcQToOrHL/uj8asZwPiVeJwK5J/lbaEOZUUiPtcq4QkjNsbb8xuYBqLMUA +tfHNSNJfnt9iv5ZSTOS2CG0bQS0Y5x91qfHj2Glxf9N8qKXW+Z/44yEdeGDRTynoLn4 n9rw== X-Gm-Message-State: AC+VfDyBceZK2csok70qNrruakd4kNpfWr/cBsQpF9zGnDAuLqtbRkA6 SaazbaETp9n/lMh3G3M32mL1eB/TgZo= X-Google-Smtp-Source: ACHHUZ437cIJli/ULgLdeFzPEgK95ScQm/hDhY+E7X0OFPp/8dUC4pNALOtbSHt/oLytLDwpkUoTVw== X-Received: by 2002:a05:6a20:12c6:b0:104:f9d4:1423 with SMTP id v6-20020a056a2012c600b00104f9d41423mr9160203pzg.28.1684142856811; Mon, 15 May 2023 02:27:36 -0700 (PDT) Received: from wheely.local0.net ([202.168.30.146]) by smtp.gmail.com with ESMTPSA id n20-20020aa79054000000b006466f0be263sm11387818pfo.73.2023.05.15.02.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:27:36 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Cc: Nicholas Piggin , qemu-devel@nongnu.org, Daniel Henrique Barboza Subject: [PATCH v3 9/9] target/ppc: Better CTRL SPR implementation Date: Mon, 15 May 2023 19:26:55 +1000 Message-Id: <20230515092655.171206-10-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515092655.171206-1-npiggin@gmail.com> References: <20230515092655.171206-1-npiggin@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=npiggin@gmail.com; helo=mail-pf1-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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The CTRL register is able to write bit zero, and that is reflected in a bit field in the register that reflects the state of all threads in the core. TCG does not implement SMT, so this just requires mirroring that bit into the first bit of the thread state field. Signed-off-by: Nicholas Piggin --- Since v2: unchanged (moved to end of series). target/ppc/translate.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index c03a6bdc9a..b5b9a0bcaa 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -413,7 +413,14 @@ void spr_write_generic(DisasContext *ctx, int sprn, int gprn) void spr_write_CTRL(DisasContext *ctx, int sprn, int gprn) { - spr_write_generic32(ctx, sprn, gprn); + /* This does not implement >1 thread */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + tcg_gen_extract_tl(t0, cpu_gpr[gprn], 0, 1); /* Extract RUN field */ + tcg_gen_shli_tl(t1, t0, 8); /* Duplicate the bit in TS */ + tcg_gen_or_tl(t1, t1, t0); + gen_store_spr(sprn, t1); + spr_store_dump_spr(sprn); /* * SPR_CTRL writes must force a new translation block,