From patchwork Mon Mar 15 18:46:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 400531 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3677504jai; Mon, 15 Mar 2021 11:56:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBFPX7smVxaDiEPcdUH0OdZM6MAd41kxLGrrRef++4v1x7xVbOObIDB1r6hcSoMKexzFXD X-Received: by 2002:a02:a809:: with SMTP id f9mr10699427jaj.63.1615834581326; Mon, 15 Mar 2021 11:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615834581; cv=none; d=google.com; s=arc-20160816; b=BILSQlzJVsldLpdZP7NgN0upO/QaNROZgVzkFTbIU+yHlx+So29oSJrcmSUv+MJ7Yw e6d5VzNnAuaoufOpNJz7W1tH/BnNvh6Eu9i6Wz1J6AcXl6BL20QG1TtLVTxRB68FKapm U/X2i6fNNsgSacSTe8NIqe2T95BSvEDBcn5klljSQ178aNFsaPl95r+EqqO+skZDlf3W SRAcbkfqxuIUzmzWbCMO+8/3yMJtl3VdCHwXP6mkNa7ZpHVDkc6nj8FklALm4oa5wVdS GyB3XZBykqGRsd17miZ1G2IYEmc1AqpK7eHEvsOp2qR1gmcLsmJz7LWFaiRD7Vh9jwP5 zZIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=8V/dpCgOxiVauvo1HWnH9SJMMk44GHfb0bI5oWyk9l8=; b=psOWKcpnI3jzbZiKLJePcBxVbc/fIlYE6PbpHMNmbu/cT620f7O3TnYsRZyVeMOJna JPBR1TszWKs326A2ND5IXOE3onN05fMqUQIMELKTHC/qHAeN9RuiudVMBK43oPMQBu47 BqO+JFv4nRIY2n7iIKE2Lzpkugsmw2DG5DPK72nk7sqMucwukV02iMuYIgEe/qaIxMSq 2rTJSl0+RsQ1yQS662cKcROoTC62+PAuQBbEiJFPRvnWiGzY9p8S/RHsNBmZQINDmTNP Woo6/X6wbwMN/QPli6YNQyiUSeLSsGJGZlskI8ymHLSVM7GQBNZ3YstiCvJs13luDdmH TvKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FeWIng7O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c5si11491127jam.17.2021.03.15.11.56.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Mar 2021 11:56:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FeWIng7O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:32882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLsO4-00039q-NE for patch@linaro.org; Mon, 15 Mar 2021 14:56:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLsES-00072M-Fc for qemu-devel@nongnu.org; Mon, 15 Mar 2021 14:46:24 -0400 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]:46895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLsEP-0001Y2-9O for qemu-devel@nongnu.org; Mon, 15 Mar 2021 14:46:24 -0400 Received: by mail-oi1-x231.google.com with SMTP id w125so6922949oib.13 for ; Mon, 15 Mar 2021 11:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8V/dpCgOxiVauvo1HWnH9SJMMk44GHfb0bI5oWyk9l8=; b=FeWIng7OznLt8jxHJbocn9n1Y78GTPAQ0iS7l/9xG6w21MeJser2mLMIWaJH8Xijbs e2Gq44MESqNFEDTox+L/M+vHjLHj3wK/BWki8aoYT54f8sQ6zBhWR0cGuZCB0qUfcG59 1STCPWycryKXnf7jzWLMTknfVvINgQO8xvmL9aZVA9g8/wEmIAiExlpF8VpPqTkvWSvn s1F3XtL1dVLa3t1HE2RJDxJ78U+cEaZx/BrTiqHRuDmu4enjoKKQXeeTBZh8xO7dzOH7 KiOtt7ck/RqYF8BmNufQzp1mQvfK6UXKElEWHSEMlVJdbptdrBTWwzhQDM7SH+DvPHxt UbOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8V/dpCgOxiVauvo1HWnH9SJMMk44GHfb0bI5oWyk9l8=; b=BZ46/CvIIv68t5QaLB/O9tktiW0TEXRnA1V1ke4ucWWWi5jb8Ge7cNKOsaKNX2Cy4w /lJN/uDTtKJIwZ0+lOpVkQpUVYPqpRF5TQTUjp8C5lSiU1gZ5EoJwJwDqZiDM0DKcpYO i9uPqVZL9yrwmXHaGQJ0NighObfxe3ZOB/k51DAKxnDkGnOuhL4OEBpxldnaRrpm03oS UPCk5s2nIdBftRogcUPe2Lye2I132H4Q/kKcCc/68HD7jopxaWkeiNfkXFPLLfkP5i99 jVYrqVWoayZmGcnoSB3ktfJOa/P63cF6cEgbAP4+nMlwT7tKL8nawznN/eL5OmGo1PZ/ RmLw== X-Gm-Message-State: AOAM532M9LkqQVLOErzZpLOHBVn57Vi3FEPEEheXHZG/DMYLUrBqujS7 LjmsFSa+Kh0KNnkJmuTk+BIoGFRpZ3nBBWMS X-Received: by 2002:aca:1904:: with SMTP id l4mr346489oii.159.1615833980127; Mon, 15 Mar 2021 11:46:20 -0700 (PDT) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id o25sm7519851otk.11.2021.03.15.11.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 11:46:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 02/17] target/ppc: Move 601 hflags adjustment to hreg_compute_hflags Date: Mon, 15 Mar 2021 12:46:00 -0600 Message-Id: <20210315184615.1985590-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210315184615.1985590-1-richard.henderson@linaro.org> References: <20210315184615.1985590-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::231; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x231.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Keep all hflags computation in one place, as this will be especially important later. Introduce a new POWERPC_FLAG_HID0_LE bit to indicate when LE should be taken from HID0. This appears to be set if and only if POWERPC_FLAG_RTC_CLK is set, but we're not short of bits and having both names will avoid confusion. Note that this was the only user of hflags_nmsr, so we can perform a straight assignment rather than mask and set. Signed-off-by: Richard Henderson --- target/ppc/cpu.h | 2 ++ target/ppc/helper_regs.c | 13 +++++++++++-- target/ppc/misc_helper.c | 8 +++----- target/ppc/translate_init.c.inc | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-) -- 2.25.1 Reviewed-by: Cédric Le Goater diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index e73416da68..061d2eed1b 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -581,6 +581,8 @@ enum { POWERPC_FLAG_TM = 0x00100000, /* Has SCV (ISA 3.00) */ POWERPC_FLAG_SCV = 0x00200000, + /* Has HID0 for LE bit (601) */ + POWERPC_FLAG_HID0_LE = 0x00400000, }; /*****************************************************************************/ diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index 5e18232b84..95b9aca61f 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -96,8 +96,17 @@ void hreg_compute_hflags(CPUPPCState *env) hflags_mask |= (1ULL << MSR_CM) | (1ULL << MSR_SF) | MSR_HVB; hreg_compute_mem_idx(env); env->hflags = env->msr & hflags_mask; - /* Merge with hflags coming from other registers */ - env->hflags |= env->hflags_nmsr; + + if (env->flags & POWERPC_FLAG_HID0_LE) { + /* + * Note that MSR_LE is not set in env->msr_mask for this cpu, + * and so will never be set in msr or hflags at this point. + */ + uint32_t le = extract32(env->spr[SPR_HID0], 3, 1); + env->hflags |= le << MSR_LE; + /* Retain for backward compatibility with migration. */ + env->hflags_nmsr = le << MSR_LE; + } } void cpu_interrupt_exittb(CPUState *cs) diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c index 5d6e0de396..63e3147eb4 100644 --- a/target/ppc/misc_helper.c +++ b/target/ppc/misc_helper.c @@ -194,16 +194,14 @@ void helper_store_hid0_601(CPUPPCState *env, target_ulong val) target_ulong hid0; hid0 = env->spr[SPR_HID0]; + env->spr[SPR_HID0] = (uint32_t)val; + if ((val ^ hid0) & 0x00000008) { /* Change current endianness */ - env->hflags &= ~(1 << MSR_LE); - env->hflags_nmsr &= ~(1 << MSR_LE); - env->hflags_nmsr |= (1 << MSR_LE) & (((val >> 3) & 1) << MSR_LE); - env->hflags |= env->hflags_nmsr; + hreg_compute_hflags(env); qemu_log("%s: set endianness to %c => " TARGET_FMT_lx "\n", __func__, val & 0x8 ? 'l' : 'b', env->hflags); } - env->spr[SPR_HID0] = (uint32_t)val; } void helper_store_403_pbr(CPUPPCState *env, uint32_t num, target_ulong value) diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.inc index c03a7c4f52..049d76cfd1 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -5441,7 +5441,7 @@ POWERPC_FAMILY(601)(ObjectClass *oc, void *data) pcc->excp_model = POWERPC_EXCP_601; pcc->bus_model = PPC_FLAGS_INPUT_6xx; pcc->bfd_mach = bfd_mach_ppc_601; - pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_RTC_CLK; + pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_RTC_CLK | POWERPC_FLAG_HID0_LE; } #define POWERPC_MSRR_601v (0x0000000000001040ULL) @@ -5485,7 +5485,7 @@ POWERPC_FAMILY(601v)(ObjectClass *oc, void *data) #endif pcc->bus_model = PPC_FLAGS_INPUT_6xx; pcc->bfd_mach = bfd_mach_ppc_601; - pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_RTC_CLK; + pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_RTC_CLK | POWERPC_FLAG_HID0_LE; } static void init_proc_602(CPUPPCState *env)