From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5005AC0015E for ; Sun, 16 Jul 2023 19:58:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230374AbjGPT6U (ORCPT ); Sun, 16 Jul 2023 15:58:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230372AbjGPT6S (ORCPT ); Sun, 16 Jul 2023 15:58:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B2A1EE for ; Sun, 16 Jul 2023 12:58:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0C3A460E8C for ; Sun, 16 Jul 2023 19:58:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15895C433C9; Sun, 16 Jul 2023 19:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689537496; bh=9J53e3s1SoXI3z73Kc/TIi4bfGnh+1pgYecTykMruaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RQ/V3KCvfKIw1ARXbbTepXfkWGW7xZYTnvo9pTaqzOZsrUzfOh1qt71LPwPSMKNSo +HqccmX/bA+OAhc3gxAzxQTMiZ51QF4Gx/OE2wZy3PvsC/Lfarlf4hhpBXLQ6Xka4U +o2rJjCYAnlY+IikvdazrORBvnbKtNO7lDt9Hqkg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Juergen Gross , "Borislav Petkov (AMD)" , Michael Kelley , Sasha Levin Subject: [PATCH 6.4 089/800] x86/hyperv: Set MTRR state when running as SEV-SNP Hyper-V guest Date: Sun, 16 Jul 2023 21:39:02 +0200 Message-ID: <20230716194951.176484676@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230716194949.099592437@linuxfoundation.org> References: <20230716194949.099592437@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Juergen Gross [ Upstream commit c957f1f3c498bcce85c04e92e60afbae1fd10cde ] In order to avoid mappings using the UC- cache attribute, set the MTRR state to use WB caching as the default. This is needed in order to cope with the fact that PAT is enabled, while MTRRs are not supported by the hypervisor. Fixes: 90b926e68f50 ("x86/pat: Fix pat_x_mtrr_type() for MTRR disabled case") Signed-off-by: Juergen Gross Signed-off-by: Borislav Petkov (AMD) Tested-by: Michael Kelley Link: https://lore.kernel.org/r/20230502120931.20719-5-jgross@suse.com Signed-off-by: Borislav Petkov (AMD) Signed-off-by: Sasha Levin --- arch/x86/hyperv/ivm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c index cc92388b7a999..6f7c1b5606ad4 100644 --- a/arch/x86/hyperv/ivm.c +++ b/arch/x86/hyperv/ivm.c @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef CONFIG_AMD_MEM_ENCRYPT @@ -372,6 +373,9 @@ void __init hv_vtom_init(void) x86_platform.guest.enc_cache_flush_required = hv_vtom_cache_flush_required; x86_platform.guest.enc_tlb_flush_required = hv_vtom_tlb_flush_required; x86_platform.guest.enc_status_change_finish = hv_vtom_set_host_visibility; + + /* Set WB as the default cache mode. */ + mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK); } #endif /* CONFIG_AMD_MEM_ENCRYPT */ -- 2.39.2