From patchwork Tue May 4 05:52:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 430807 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp3491993jao; Mon, 3 May 2021 23:02:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjocjNwKhl1+3U055MUaiFANpV/OYEGT0gwH2fuACPKy3nCGdPnYyKl36gvMUOqC+M21hM X-Received: by 2002:a1f:9f52:: with SMTP id i79mr3406015vke.4.1620108165686; Mon, 03 May 2021 23:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620108165; cv=none; d=google.com; s=arc-20160816; b=o0PkhiPN63DwzrSFwTjsC5aljt/zW7TmISxClSapeFq6gbUeIzZCV6Wy2yLNvFBUqM G4rY4aEfuyOKN1h30G9UBimuNMskwhaMvSR2l1xFJSbHujLp89RRHlwfghctuei3/WcS x+P9AJ8nby+lwSRqRPSUPX+371PuEXqUV9EUm7mumyhmIfSUHQiliugoREo97JYEwrw9 a8JkE5XOm0vdjVsu/O01lUB98EDkDGppN9wJp1L5xw8qAo/K7nZoePFqVbO68wvQclj+ nJbh5JKVk5SfJz7fQMrZ66jQU3dr9v7+EBXIziHlrJZS8hZy3hHEZnYB7dV6DB2IrAYT wk7w== 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=6v08F6blIcGV/3NI8SOrczoDm5+DUWf0wbrmkm8j+o4=; b=j7E5Np7/VEL9tjZk/dcLJtVsVX+U2YQlTs9nk/vhP0Vkg2g8RYTU0ejuyr86+upvx5 7x9X7jrZ7Rgt4eZgqhfVDiibix/oJzdHv1K2QnOWppR1CmnOdBCJ2B813NFWE7FP3BNP ovuA+6VQmYAcBLY3A5LLzUeFba41ircGoV2TlQ/5yxh+2Iefz4qut9HNQoin1GkGqb9y NQ750uY1RziaDLSVfABUOnu7cSLya+odz9UEvNF6PMeqWxJv5HhGXXgA+tBM4iorO2aJ Q/1wwNTc85531AKQvm6rvVzTc8y7WYqVcb0BYinzGmQEefAO4eBfGsz0kcsNK+/57Rgo xIEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=QazuReSh; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t6si1219512ual.185.2021.05.03.23.02.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 May 2021 23:02:45 -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=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=QazuReSh; 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" Received: from localhost ([::1]:37290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldo8r-0005UC-28 for patch@linaro.org; Tue, 04 May 2021 02:02:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldnzy-0005ER-RK; Tue, 04 May 2021 01:53:36 -0400 Received: from ozlabs.org ([203.11.71.1]:60029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldnzu-0004fy-L1; Tue, 04 May 2021 01:53:33 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 4FZ8CK2HFbz9sWP; Tue, 4 May 2021 15:53:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1620107597; bh=oW4gZLOC55a8GtLu9aFZEjL0E+dLRASXBtOs5tL/xpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QazuReShYv9d9YYcApIrSml4UbUWrVzhLV+hxfZe5Ow0OOi4S7XBexXu/ne0Qp9ES aehyZPoD+h0GLBkgd2pkXSfRLDqFs1IcspLlZAZLKUu7npRVLvHNspKzqdpTYcdbKL Tz+lDt6nglU6KxlFyT9hE6EwZ+UTzYD7e0vcyaSQ= From: David Gibson To: peter.maydell@linaro.org, groug@kaod.org Subject: [PULL 10/46] target/ppc: Extract post_load_update_msr Date: Tue, 4 May 2021 15:52:36 +1000 Message-Id: <20210504055312.306823-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210504055312.306823-1-david@gibson.dropbear.id.au> References: <20210504055312.306823-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Extract post_load_update_msr to share between cpu_load_old and cpu_post_load in updating the msr. Suggested-by: Cédric Le Goater Signed-off-by: Richard Henderson Message-Id: <20210323184340.619757-2-richard.henderson@linaro.org> Signed-off-by: David Gibson --- target/ppc/machine.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) -- 2.31.1 diff --git a/target/ppc/machine.c b/target/ppc/machine.c index 1f7a353c78..09c5765a87 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -10,6 +10,18 @@ #include "kvm_ppc.h" #include "exec/helper-proto.h" +static void post_load_update_msr(CPUPPCState *env) +{ + target_ulong msr = env->msr; + + /* + * Invalidate all supported msr bits except MSR_TGPR/MSR_HVB + * before restoring. Note that this recomputes hflags and mem_idx. + */ + env->msr ^= env->msr_mask & ~((1ULL << MSR_TGPR) | MSR_HVB); + ppc_store_msr(env, msr); +} + static int cpu_load_old(QEMUFile *f, void *opaque, int version_id) { PowerPCCPU *cpu = opaque; @@ -21,7 +33,6 @@ static int cpu_load_old(QEMUFile *f, void *opaque, int version_id) int32_t slb_nr; #endif target_ulong xer; - target_ulong msr; for (i = 0; i < 32; i++) { qemu_get_betls(f, &env->gpr[i]); @@ -117,13 +128,7 @@ static int cpu_load_old(QEMUFile *f, void *opaque, int version_id) qemu_get_sbe32(f); /* Discard unused mmu_idx */ qemu_get_sbe32(f); /* Discard unused power_mode */ - /* - * Invalidate all supported msr bits except MSR_TGPR/MSR_HVB - * before restoring. Note that this recomputes hflags and mem_idx. - */ - msr = env->msr; - env->msr ^= env->msr_mask & ~((1ULL << MSR_TGPR) | MSR_HVB); - ppc_store_msr(env, msr); + post_load_update_msr(env); return 0; } @@ -343,7 +348,6 @@ static int cpu_post_load(void *opaque, int version_id) PowerPCCPU *cpu = opaque; CPUPPCState *env = &cpu->env; int i; - target_ulong msr; /* * If we're operating in compat mode, we should be ok as long as @@ -417,13 +421,7 @@ static int cpu_post_load(void *opaque, int version_id) ppc_store_sdr1(env, env->spr[SPR_SDR1]); } - /* - * Invalidate all supported msr bits except MSR_TGPR/MSR_HVB - * before restoring. Note that this recomputes hflags and mem_idx. - */ - msr = env->msr; - env->msr ^= env->msr_mask & ~((1ULL << MSR_TGPR) | MSR_HVB); - ppc_store_msr(env, msr); + post_load_update_msr(env); return 0; }