Received: by 2002:ab2:7104:0:b0:1f7:f6c3:9cb1 with SMTP id z4csp44875lql; Tue, 7 May 2024 09:19:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVB+UdTvVrKlj+T+AxE2jz3n5a2Y9VI0+iP+T2HhnXzbLd3gXvYrk7XK+U+/gaopzw0RLy7lh7fpFUOtLcHf8WLVaBSObib+0hAdbwJlQ== X-Google-Smtp-Source: AGHT+IEiijJ1cXsQ2SUdnib/BvNJEqNRvv1qY3lDaV23IuraWzFGNTUPpjNo3MEkzwKdnXLrI4Di X-Received: by 2002:a50:9993:0:b0:56e:2ebc:5c4 with SMTP id 4fb4d7f45d1cf-5731d9db2f4mr163449a12.20.1715098760349; Tue, 07 May 2024 09:19:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715098760; cv=pass; d=google.com; s=arc-20160816; b=dL0DI+DEd0ntQOIj4BNmubA45ZusVqUBPrHs0y72LROcMVSxS1B7JeibsS2wfI1Ex9 LUTzz7cscYZ/cZVVx4piGlPEZLOhCh+vdHZpNKiwodLy9+tTp7gtQ1Qn4O6+j6bGoE0C Vo3kqTWh79+s9XJoY5LMGrkKppQQdbHho9ztQtZ+zOmGNTU53ZE9RT6cqgUM0u81fSSh onno/QUUyHSRH/mADGYHm88Z5+DBXCPxSWw3OFF0U9Pjc33E1WPQV08A1EkGytw4mJFQ FbQZo7eG9K3U+/2ynjSjnTC+vwvVDnT4bnaGaQh9G3FAG7yYlbFu2aQTFSsCLNSF3Ny9 ciAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PhSF5CLyMvZ9q5422nBduiCJ8agqIGSpdDou5cmGsPw=; fh=ZzFhOPU4F3Fa2UhGVAjpaB/PrQqmJJmai45vQY5deVI=; b=qcksOuRy1cTi0LKzuxiyOSVqGC0asuBlmUG6W3TfbdW65PBHFkFrDLqXKUP4FV9JS8 lKm2xqBenNqF8SFfiJ6tPaXIPd4FyxytpPYQr4xdVU7nCHG/Z+OCFLKchVp64EwBg/8t WaSMlUbPKBp45AFkct2+2guB8ws2nHujpah1oorzLsW6MHJVjazUq7H55VGTQI1Ao/xx ivcORCTujGcXLPJYuO+a3Lsm/uEdNkZP33EGXG9ohdzsIg98qR1o1ajLFI7iJstR0z5R 9cJ7H/OdU9qHO2nZuABaEbI+38deCNfjn7y34VE+W0C2wtqsdV5oQ+YqrKCqEY3UAZP+ nSvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WSDtMEID; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-171745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171745-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id eg38-20020a05640228a600b005727132a2d6si6192553edb.165.2024.05.07.09.19.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 09:19:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WSDtMEID; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-171745-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171745-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 42C161F286AA for ; Tue, 7 May 2024 15:59:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F002616C86B; Tue, 7 May 2024 15:58:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WSDtMEID" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8C9F168AEB for ; Tue, 7 May 2024 15:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715097504; cv=none; b=V3S4vLjKjBId7mb1PIMIlnHcgGf09PvfJNdrUC2KA7SHwmSVoBb7CdpJbm/qeI7dopR69Usp6JDQRnMmc6aAyW4KVsN3PFSvHGIxo5IuOVBdP39fJwwb8XPsGmDfE6hhVAJyNEqwFlHEHqH2mGiaDAa72TsgCf1KgiVOH29rqIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715097504; c=relaxed/simple; bh=VhDDefLstbHru7ZdZYPe2kSJKdJZTzVm7iepiZxsKjI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q81464uNwZwoIbjPB7KqeeZdKl32DUc116r4eO1HF/EF8NiI87DmBa4cZ0Sk9xvZBoSJasXtHH0tEgsVJHQleyCv75AVCR/nP0Mdj4IxnUUB+EyxIiS4zphest8UWwAljN+XUxuEPFwjEz8TitKJib5Hj97EnVBENBjNKnAQ2kM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WSDtMEID; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715097502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PhSF5CLyMvZ9q5422nBduiCJ8agqIGSpdDou5cmGsPw=; b=WSDtMEIDhzjIU4lUBd0sqka7ZrP5GsSd+hNgO+5y9ss2JiChpF1eBeeyNkbjYhP1PJqr/w KnsCGV3KZNI1U4yOXfJqz8EbrCjyvgYgVVX4/jK1ehovG9vKthcWF8jdbdNoxPsnR2Xejw RT5cXQ/NwNmmP3clINlDj+KP24wmmLQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-318-zk09axuqPlqCtT6mVwWP5A-1; Tue, 07 May 2024 11:58:18 -0400 X-MC-Unique: zk09axuqPlqCtT6mVwWP5A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 786973C025D9; Tue, 7 May 2024 15:58:18 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C641200B2F6; Tue, 7 May 2024 15:58:18 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson Subject: [PATCH 03/17] KVM: x86: Define more SEV+ page fault error bits/flags for #NPF Date: Tue, 7 May 2024 11:58:03 -0400 Message-ID: <20240507155817.3951344-4-pbonzini@redhat.com> In-Reply-To: <20240507155817.3951344-1-pbonzini@redhat.com> References: <20240507155817.3951344-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 From: Sean Christopherson Define more #NPF error code flags that are relevant to SEV+ (mostly SNP) guests, as specified by the APM: * Bit 31 (RMP): Set to 1 if the fault was caused due to an RMP check or a VMPL check failure, 0 otherwise. * Bit 34 (ENC): Set to 1 if the guest’s effective C-bit was 1, 0 otherwise. * Bit 35 (SIZEM): Set to 1 if the fault was caused by a size mismatch between PVALIDATE or RMPADJUST and the RMP, 0 otherwise. * Bit 36 (VMPL): Set to 1 if the fault was caused by a VMPL permission check failure, 0 otherwise. Note, the APM is *extremely* misleading, and strongly implies that the above flags can _only_ be set for #NPF exits from SNP guests. That is a lie, as bit 34 (C-bit=1, i.e. was encrypted) can be set when running _any_ flavor of SEV guest on SNP capable hardware. Signed-off-by: Sean Christopherson Message-ID: <20240228024147.41573-4-seanjc@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/kvm_host.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index a047480da5af..58bbcf76ad1e 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -261,8 +261,12 @@ enum x86_intercept_stage; #define PFERR_FETCH_MASK BIT(4) #define PFERR_PK_MASK BIT(5) #define PFERR_SGX_MASK BIT(15) +#define PFERR_GUEST_RMP_MASK BIT_ULL(31) #define PFERR_GUEST_FINAL_MASK BIT_ULL(32) #define PFERR_GUEST_PAGE_MASK BIT_ULL(33) +#define PFERR_GUEST_ENC_MASK BIT_ULL(34) +#define PFERR_GUEST_SIZEM_MASK BIT_ULL(35) +#define PFERR_GUEST_VMPL_MASK BIT_ULL(36) #define PFERR_IMPLICIT_ACCESS BIT_ULL(48) #define PFERR_NESTED_GUEST_PAGE (PFERR_GUEST_PAGE_MASK | \ -- 2.43.0