Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2662403rbb; Wed, 28 Feb 2024 08:39:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUVk2mFe19ovimdurYOa4i7ql8uSQrBsalqQ8U50Pn1MQ4Yu13P/dSpfJ7R4ojw0VHJUP9vmbRWPRwGkIoJg2kkOAz7Ag/uyoPx8yRzpQ== X-Google-Smtp-Source: AGHT+IF3yjBayW/hc4wDb80fhxzqqAqNfZjH7wRBS7bM1bG2o7XBklFLP5Om4qPM15WUWY76bV0e X-Received: by 2002:a17:90b:3595:b0:299:48db:1920 with SMTP id mm21-20020a17090b359500b0029948db1920mr3967261pjb.3.1709138385411; Wed, 28 Feb 2024 08:39:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709138385; cv=pass; d=google.com; s=arc-20160816; b=KpzNEDkk0ygASGAq55C5oJjoHn6Pzrk5R6ed8fCQoXs84ixngNx9oLrHpFpA3eXkxp w8IRm3GnbBVlTbZ5hj+o1G+Otg9rodkv3twCqCuQQz9z/lxhG/uFM6B16G69cGZDc+Q6 wmda9gcl0ac5Uu3eTenmefEEbAX4+Acrpe0x/2qxLN3oD4ndNRqRpKz0qp+VNYk+Jwty 4HMvHd7nUsLXLHSvSV6JrHp5pWwTTsxYrGUqYGnpnBziefIArNfwE+mhLgkMEcqCwiPM R2EUl9RiM+MbEcWaCD86bWkyV4BVYu2n0uD5WJ3bWEEhhLixGzW0R+QOGgskhaTiUC9E 5glw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=in1G4Nf0xBzdZL+ZLfa80V34ZfSkT4yQR98VuhCKCF4=; fh=3MI4bsUq5Tu0FLJus7Axcem2jDGCHw+ZY2hxOAue5HI=; b=MyhY8pQg+WIXST3KwG4QaAF/WnLXRo9kO0d/JdOkZtdi6iNR04O5H/qpoW6aSX06m9 GJOPeeGw1CaY+k9vgXLmomB7W6jM5hI1ysQntodHOfBzTfs+9UXASwn/4taCQzkhakMc FIJ6qD0nOM2irpyM1icUkPPM6VYYA4k4fYw1Lqos6B4sLB5T1lEGy9H4fVFtz5qMJsJb nTO4sxWcIZdYTCcYGxcIhLnXO/0aDbwU04VWg5+GBe3zczc16D59rdJCDyUSe3h733DK ewh7upVrkwthc4xQ/i29T1dWSPnBBMJmAYaUE32cIZtJCAgtC1d8uVRpd/kdTCuZSq3l 8brA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=a6FzsXR8; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85378-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id pi6-20020a17090b1e4600b0029a38eabbe5si1672638pjb.94.2024.02.28.08.39.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 08:39:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=a6FzsXR8; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-85378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85378-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 22EF328C2E8 for ; Wed, 28 Feb 2024 16:39:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E4BB159591; Wed, 28 Feb 2024 16:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="a6FzsXR8" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E972313541F for ; Wed, 28 Feb 2024 16:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709138353; cv=none; b=ihbZDX7LFK/FHntMphUrDf2DfRull6ywuY5YoP8ifIsKJv1ChspxkyfwC/umU2/KMc0c6lcFTCd43Tcy+fjfluF2QlNieIyj1OTFq3lDnBw+V+1TyrFQYmLNzC+WVL3zOZswOg65t3iyqELo6b0z8F3j50g5V0me8SOj+FGknus= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709138353; c=relaxed/simple; bh=WiX9KtC09wJJPUJJv7ze4L+SsXIBO6G3kahrWm3FGSY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IgWjHetskof+Y74FNyuDdvjbktCp5hnilqAJBgqEUs8G9ll0D+tdUyzVhToROnyYu2mSqd3qWs2hqTba4ac0syka2muvI4vQg1T2I2daS5BXU5SNdZkwbj7I68SOdyszpKhv3RnqwU/YNNsFNwcIR2NNLX+I2q6vS5/u8Z7828Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=a6FzsXR8; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcbfe1a42a4so10877883276.2 for ; Wed, 28 Feb 2024 08:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709138351; x=1709743151; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=in1G4Nf0xBzdZL+ZLfa80V34ZfSkT4yQR98VuhCKCF4=; b=a6FzsXR8SB7SYky2iq60UtmubtZYgpRK3/8bDVgPdSyPZADqtHa4FlWe9i75HSi6f2 BJGHqGR8USbY4jqa4+mScSkTrT/2LbfLyrX4DTBwQcP8qk7cLlzWoJfIizAhBBFoVMSC 6FDI4qoujRKKzbz1bmaMgQH15GOHYznlWqTj5GLOnPY/SSde1i11bUgg5Sqg5gah2jhR UgR2J+D03P/+lkXTBEEjMK3eOuIlGvoCByvYCcGOl1dZ+/Z1+pwWPf1CoOMCgOx/wDp9 cYSHF4JACV/Qi1nbTs1TQ1rmyA0h+f6pW7soj8hro5Xuyd7+LhM3+lvZv2B2X2VOm9zv tzng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709138351; x=1709743151; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=in1G4Nf0xBzdZL+ZLfa80V34ZfSkT4yQR98VuhCKCF4=; b=LS6EuQYsjx33p1vRkZ5f1+a3leRGhZ58SdPbm1IKJRuEvOMLjbIO58H+AnZSAVSgix g5zISXrd3DNYdKecmqx2lsKlGgr6qKL8qdVjSpPKcei3jwPbA+zhKo8sz42qnq3xH0+O W3aIy4tEN85LJHzs5+3xWkCMn0b0tcJ65SiZNq/Hv7FZognRAiIbIhR3C4b0pZfowMzP gcwxUaVQL3HM7VhJ+XxR5/9IT+k2Male11jzuUAvqpuQxg1zm5xAb/IWXNfFVB4iOOJN DtgWpEfWAMfLFxflCULmswUPEvmhRYtGdMjySfXc83m3gb81wkA+uThq3TGAhLtg/f/A S5ZA== X-Gm-Message-State: AOJu0Yz3Z+dgq1aUOLu2kY7Y8vPg2dKhTiSUHa1lFvw2ptmbag2BRt6d 2sEYVF6oY+ZePXRzeEQD7+k0yFY8O47FOxO7UTFABpSn7+DdwzOvSUaBBFt03+sGsICzErpKUMn Lvw== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1507:b0:dc6:e1ed:bd1a with SMTP id q7-20020a056902150700b00dc6e1edbd1amr835132ybu.2.1709138350982; Wed, 28 Feb 2024 08:39:10 -0800 (PST) Date: Wed, 28 Feb 2024 08:39:09 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240227232100.478238-1-pbonzini@redhat.com> Message-ID: Subject: Re: [PATCH 00/21] TDX/SNP part 1 of n, for 6.9 From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, michael.roth@amd.com, isaku.yamahata@intel.com, thomas.lendacky@amd.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 28, 2024, Paolo Bonzini wrote: > On Wed, Feb 28, 2024 at 2:25=E2=80=AFAM Sean Christopherson wrote: > > > Michael Roth (2): > > > KVM: x86: Add gmem hook for invalidating memory > > > KVM: x86: Add gmem hook for determining max NPT mapping level > > > > > > Paolo Bonzini (6): > > > KVM: x86/mmu: pass error code back to MMU when async pf is ready > > > KVM: x86/mmu: Use PFERR_GUEST_ENC_MASK to indicate fault is private > > > > This doesn't work. The ENC flag gets set on any SNP *capable* CPU, whi= ch results > > in false positives for SEV and SEV-ES guests[*]. >=20 > You didn't look at the patch did you? :) Guilty, sort of. I looked (and tested) the patch from the TDX series, but = I didn't look at what you postd. But it's a moot point, because now I did look at w= hat you posted, and it's still broken :-) > It does check for has_private_mem (alternatively I could have dropped the= bit > in SVM code for SEV and SEV-ES guests). The problem isn't with *KVM* setting the bit, it's with *hardware* setting = the bit for SEV and SEV-ES guests. That results in this: .is_private =3D vcpu->kvm->arch.has_private_mem && (err & PFERR_GUEST_ENC= _MASK), marking the fault as private. Which, in a vacuum, isn't technically wrong,= since from hardware's perspective the vCPU access was "private". But from KVM's perspective, SEV and SEV-ES guests don't have private memory, they have mem= ory that can be *encrypted*, and marking the access as "private" results in vio= lations of KVM's rules for private memory. Specifically, it results in KVM trigger= ing emulated MMIO for faults that are marked private, which we want to disallow= for SNP and TDX. And because the flag only gets set on SNP capable hardware (in my limited t= esting of a whole two systems), running the same VM on different hardware would re= sult in faults being marked private on one system, but not the other. Which mea= ns that KVM can't rely on the flag being set for SEV or SEV-ES guests, i.e. we can'= t retroactively enforce anything (not to mention that that might break existi= ng VMs).