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 9B047C61DA4 for ; Mon, 30 Jan 2023 09:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236169AbjA3JRn (ORCPT ); Mon, 30 Jan 2023 04:17:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbjA3JRj (ORCPT ); Mon, 30 Jan 2023 04:17:39 -0500 Received: from mail.8bytes.org (mail.8bytes.org [85.214.250.239]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F9F0166D4; Mon, 30 Jan 2023 01:17:35 -0800 (PST) Received: from 8bytes.org (p5b006afb.dip0.t-ipconnect.de [91.0.106.251]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.8bytes.org (Postfix) with ESMTPSA id 18F7C2200F6; Mon, 30 Jan 2023 10:17:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=8bytes.org; s=default; t=1675070254; bh=NdvnNtJBmKggBnVTC20VlVWcPnkhTXkX4lMw5E2q6fw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SQbpOt7SgrJmEl39TNMMzQHHBQ2en4WNAymTD0e0U6iuiRzcaqQXPJKzd/QS+l8eH IRsOo/hmLutpBSsd+izIVLJJO7GOrvAKR0f0/7tsV0v8rygMy2PjxKxTH9zXBVLod/ mIIFCxUgHhcxl9TsLcJDXMXpQCt8aOkPqAmhCse2/RR03dWskEdOc+DKeLJ8L/jAtf LGJ1cmqA8fgsXncho3nkN/jdtuqEG3Rmeb0Cq4v9shjKUohQcSP+KLlDlQSz3+mivB 6FVj/JjvuanISAZ+WODsSuyfSOk98YL9u83t6WtHN87PgMOcxQT2vC2wB9DGkVoKk8 JqFBi0Memi3XQ== Date: Mon, 30 Jan 2023 10:17:32 +0100 From: Joerg Roedel To: Alexey Kardashevskiy Cc: Peter Zijlstra , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Sean Christopherson , Jiri Kosina , Ingo Molnar , Dave Hansen , Borislav Petkov , "H. Peter Anvin" , Tom Lendacky Subject: Re: [Question PATCH kernel] x86/amd/sev/nmi+vc: Fix stack handling (why is this happening?) Message-ID: References: <20230127035616.508966-1-aik@amd.com> <3bb3e080-caee-8bc8-7de9-f44969f16e75@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 28, 2023 at 02:52:23PM +0100, Joerg Roedel wrote: > Yeah, something like this will be the fix. I am still thinking about > the right place to put the volatile to make it explicit to the situation > we are encountering here (which is SEV-ES specific). > > Best would be an explicit barrier in C code between sev_es_ist_enter() > and the DR7 read, but all barriers I tried to far only seem to affect > memory instructions and had no influence on the DR7 read (which is > obviously not considered as a memory read by the compiler). > > The best place to put the barrier is in the sev_es_ist_enter() inline > function, right after the static_call to __sev_es_ist_enter(). Okay, after some investigation I was not able to find a compiler barrier which affects DR7 read ordering. This leaves us with the only solution of directly forbidding DR7 register access re-ordering by adding a volatile to the asm, like you did before. I will send a fix later today. Regards, Joerg