From patchwork Mon Mar 6 16:34:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 64963 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1954723wrd; Mon, 6 Mar 2023 09:02:18 -0800 (PST) X-Google-Smtp-Source: AK7set8EQ9RIjnOixkct4nbPFIQyUV4Qs0ZNUHF2ZPVZmnzfHUa60sNEUlggl8J4maktAQioRsV/ X-Received: by 2002:aa7:c98a:0:b0:4ac:d2b4:ec2c with SMTP id c10-20020aa7c98a000000b004acd2b4ec2cmr8932138edt.29.1678122137978; Mon, 06 Mar 2023 09:02:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678122137; cv=none; d=google.com; s=arc-20160816; b=yslt9uXrtTUfLXVsNIXEik5lecRFeS/veApOYCr9ZlTTmnDhK+RAI+2kpj/s5PDO3T L3L78mhDSwbCXGxkT2jWE8ss3QXLPeNUlfUO6gq9mS9ds9I3FC+QcvvRPlDmO1yZeNFc 9mIYm0HHi4/NnRtvuHvyrJQAxk2XvxiE7+dZE43HxSqA9BTFVx5Zk0dVyVjaeV+jN/jF GcwdqkBxf2ky3jaoML/ONr7qj/tMxjscE9wlVXYmtYBUdgKScoOey0WeZ6mWp99jHdrm RJjKL6zFmvlx+eqlrFMY5vzTp9NQbiQtFNn1yEhZJPBfxVPOs7DhN21qEnwcrFOmQGnO BCoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EEyy0YGNrjiScFEJSCN9XqA2TAW4Ejl4yGBfINYDlUs=; b=Pi5poXcDx1PlqvoqpInW9Cv0UTpZYcvqJ2VWoD8iLzzEvDTSn0VC9DNfP37IWJlB/x L9C3e3Rlmg5Yp2nHj4n2oXFRhKngwAGzUKl4WyAXjoTiR4GiOdlnmRWTGRzLel206wZy IoXSmbIQ0oeTMkKeprYaGKXoo+WVYWQo72M7UZxhMw/ptUQ0k+yMpBQR7Al2wdNUyDeC +JHEwVOdwy/VOWVv8Yu9zuBFLnpLRaP+m2Sbgz54tQfcYRW0/TWiN63wImP4lSZH//M4 RdO2LBI7BDbjFz8eEaAhKbQlGiLPDBvYP3UF9ld58grTypwe0rIvOV8cawkX4l7KBk+R kq+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=hykKurK9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020aa7c586000000b004ab250bceecsi7238890edq.654.2023.03.06.09.01.53; Mon, 06 Mar 2023 09:02:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=hykKurK9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbjCFQg7 (ORCPT + 99 others); Mon, 6 Mar 2023 11:36:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbjCFQgL (ORCPT ); Mon, 6 Mar 2023 11:36:11 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53B2F4390C; Mon, 6 Mar 2023 08:35:37 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7789921E5D; Mon, 6 Mar 2023 16:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1678120490; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EEyy0YGNrjiScFEJSCN9XqA2TAW4Ejl4yGBfINYDlUs=; b=hykKurK9/WXS6qISoyLDcDHoUPTa6DT2LVEsW+HX1QsXJ0G5yeT0pc2YbmUapmb9VennA3 yx5uPl6pHjSN+PR7U5sxC+wj8Z/kbztWb3NkzdcLlXeUJXYTivVOxlBOrfZl+IdV536VzX e3PDiwTRa+CSvX3UOk/PJo5Y3opyfRA= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2756B13A66; Mon, 6 Mar 2023 16:34:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yD1zCCoWBmREUwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:34:50 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-hyperv@vger.kernel.org Cc: Juergen Gross , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v4 04/12] x86/hyperv: set MTRR state when running as SEV-SNP Hyper-V guest Date: Mon, 6 Mar 2023 17:34:17 +0100 Message-Id: <20230306163425.8324-5-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230306163425.8324-1-jgross@suse.com> References: <20230306163425.8324-1-jgross@suse.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759638598626976256?= X-GMAIL-MSGID: =?utf-8?q?1759638598626976256?= 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 --- V2: - new patch --- arch/x86/kernel/cpu/mshyperv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index f36dc2f796c5..0a6cc3cf8919 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -34,6 +34,7 @@ #include #include #include +#include /* Is Linux running as the root partition? */ bool hv_root_partition; @@ -408,6 +409,9 @@ static void __init ms_hyperv_init_platform(void) #ifdef CONFIG_SWIOTLB swiotlb_unencrypted_base = ms_hyperv.shared_gpa_boundary; #endif + + /* Set WB as the default cache mode. */ + mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK); } /* Isolation VMs are unenlightened SEV-based VMs, thus this check: */ if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT)) {