public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@amd.com>
To: <x86@kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Nikunj A Dadhania <nikunj@amd.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	Pavan Kumar Paluri <papaluri@amd.com>,
	Ashish Kalra <ashish.kalra@amd.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Michael Roth <michael.roth@amd.com>,
	Kevin Loughlin <kevinloughlin@google.com>,
	"Kuppuswamy Sathyanarayanan"
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Liam Merwick <liam.merwick@oracle.com>,
	"Alexey Kardashevskiy" <aik@amd.com>
Subject: [PATCH 0/2] x86/sev: Rework SNP Guest Request to fix race
Date: Fri, 7 Mar 2025 12:36:58 +1100	[thread overview]
Message-ID: <20250307013700.437505-1-aik@amd.com> (raw)

Guest Request is a mechanism for a SNP VM to talk to the PSP described
in the GHCB spec. GHCB allows one request in flight at the time and
there is a mutex for it: msnp_cmd_mutex. Unfortunaty series of events
led to use of shared data outside of this mutex area and recent commit
ae596615d93d ("virt: sev-guest: Reduce the scope of SNP command
mutex") broke it.

The shared data includes:

- request structures in snp_guest_dev which was not a problem when
they were introduced as they were put on stack but db10cb9b5746
("virt: sevguest: Fix passing a stack buffer as a scatterlist target")
moved them to snp_guest_dev so they became shared but there was
a mutex so it was ok (not anymore);

- data pages and the number of them in Extended Guest Request.

So here are 2 patches. Reverting ae596615d93d is not an easy option as
the code developed far enough (the mutex moved and secure TSC now
calls the PSP too) to make it rather large.


This is based on sha1
277255aa69e5 Ingo Molnar "Merge branch into tip/master: 'x86/sev'".

Please comment. Thanks.



Alexey Kardashevskiy (1):
  virt: sev-guest: Move SNP Guest Request data pages handling under
    snp_cmd_mutex

Nikunj A Dadhania (1):
  virt: sev-guest: Allocate request data dynamically

 arch/x86/include/asm/sev.h              |  6 +-
 arch/x86/coco/sev/core.c                | 23 +++-----
 drivers/virt/coco/sev-guest/sev-guest.c | 58 +++++++++++++++-----
 3 files changed, 54 insertions(+), 33 deletions(-)

-- 
2.47.1


             reply	other threads:[~2025-03-07  1:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07  1:36 Alexey Kardashevskiy [this message]
2025-03-07  1:36 ` [PATCH 1/2] virt: sev-guest: Allocate request data dynamically Alexey Kardashevskiy
2025-03-07 10:52   ` Alexey Kardashevskiy
2025-03-07 18:25   ` [tip: x86/urgent] " tip-bot2 for Nikunj A Dadhania
2025-03-07  1:37 ` [PATCH 2/2] virt: sev-guest: Move SNP Guest Request data pages handling under snp_cmd_mutex Alexey Kardashevskiy
2025-03-07  9:00   ` Nikunj A. Dadhania
2025-03-07 17:50   ` Tom Lendacky
2025-03-07 18:25   ` [tip: x86/urgent] " tip-bot2 for Alexey Kardashevskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250307013700.437505-1-aik@amd.com \
    --to=aik@amd.com \
    --cc=ardb@kernel.org \
    --cc=ashish.kalra@amd.com \
    --cc=bp@alien8.de \
    --cc=brijesh.singh@amd.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kevinloughlin@google.com \
    --cc=liam.merwick@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=nikunj@amd.com \
    --cc=papaluri@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox