From patchwork Thu Sep 8 08:49:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12969781 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 8B17FC54EE9 for ; Thu, 8 Sep 2022 08:49:35 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.402832.644730 (Exim 4.92) (envelope-from ) id 1oWDDy-0007Ft-RV; Thu, 08 Sep 2022 08:49:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 402832.644730; Thu, 08 Sep 2022 08:49:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWDDy-0007Fm-Ol; Thu, 08 Sep 2022 08:49:26 +0000 Received: by outflank-mailman (input) for mailman id 402832; Thu, 08 Sep 2022 08:49:25 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWDDx-0006wz-31 for xen-devel@lists.xenproject.org; Thu, 08 Sep 2022 08:49:25 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 23749ad3-2f53-11ed-9760-273f2230c3a0; Thu, 08 Sep 2022 10:49:24 +0200 (CEST) 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-out2.suse.de (Postfix) with ESMTPS id 235EF1F8A3; Thu, 8 Sep 2022 08:49:24 +0000 (UTC) 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 D98F31322C; Thu, 8 Sep 2022 08:49:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id FLzdM5OsGWNFNgAAMHmgww (envelope-from ); Thu, 08 Sep 2022 08:49:23 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 23749ad3-2f53-11ed-9760-273f2230c3a0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1662626964; 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=FRQlMbR3LekauN/VGAqwz3/4iPTsfJTb9AkfSRaurK0=; b=Hd9Ngqvs9Q7HjcnnFHdEJnluFdjs2Wj0yx7QF7U6WlXYjs7VkdqwdTeiOTJdFoIUG+LQfF 4GbxxQll8c0/5O+q2qlKl7gbNHHZP05WdF57KoK55JwvRKci1L2aeMv9LnUQ4xXNTmGKW3 77gVzi15lfi7uuJQtkiQDGwKbuzddZg= From: Juergen Gross To: xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v3 01/10] x86/mtrr: add comment for set_mtrr_state() serialization Date: Thu, 8 Sep 2022 10:49:05 +0200 Message-Id: <20220908084914.21703-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220908084914.21703-1-jgross@suse.com> References: <20220908084914.21703-1-jgross@suse.com> MIME-Version: 1.0 Add a comment how set_mtrr_state() is needing serialization. Suggested-by: Borislav Petkov Signed-off-by: Juergen Gross --- V3: - new patch instead of old patch 1 --- arch/x86/kernel/cpu/mtrr/generic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index 558108296f3c..cd64eab02393 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c @@ -684,7 +684,10 @@ static u32 deftype_lo, deftype_hi; /** * set_mtrr_state - Set the MTRR state for this CPU. * - * NOTE: The CPU must already be in a safe state for MTRR changes. + * NOTE: The CPU must already be in a safe state for MTRR changes, including + * measures that only a single CPU can be active in set_mtrr_state() in + * order to not be subject to races for usage of deftype_lo (this is + * accomplished by taking set_atomicity_lock). * RETURNS: 0 if no changes made, else a mask indicating what was changed. */ static unsigned long set_mtrr_state(void)