Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2440702rdg; Mon, 16 Oct 2023 04:54:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhghLXHi155urn44PKvFjBpK+cCZ+OhTbNIVHAHoVXDvmGs6eA9l7P5eXzp9otTfN6nRiI X-Received: by 2002:a17:90b:4c42:b0:27d:30ac:15b4 with SMTP id np2-20020a17090b4c4200b0027d30ac15b4mr9115788pjb.34.1697457243512; Mon, 16 Oct 2023 04:54:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697457243; cv=pass; d=google.com; s=arc-20160816; b=RaR3pSjW1rs2K2hDduMzDJn5wUNGNHiIQuHarxrI3b/c69c4Nnhb5LsZgchw/9Vc6S M1L/q7W8gXmyf11c51CZtL7g2i5IObTF4EXPLZy4ISyNkVEMeZF0zNF0fP43SsDPOzBo zuYg1t3lFXnd1vRu01L+pofE3s0C57pNIYydoqd0HMrBa+nzsu/9CgMHuadjJgQHSzLz 0ha7yiEHUR3yUtRt/LnCxeUfGgltYVyVAaM+A8Aohib/UqPUKyhjXXmQ+5AjgIXolgm6 i3H+rrWsLjNpSmzx9IDW3u3VNCKJ7tnxu6ekFfwFQbRTNEiJdY1Cl8gwbwQLtkKZzFyd vbVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/OHgKUYFAZCONnATUVnBIwfZqzs8EaYMPwtwwWj6zPA=; fh=O/33OfWh3tgBRvVucuqbtMFeS8FpVuifQ5WdKFtCmeQ=; b=Uot3SjQFpVOYdJrxJGriZtFQIrS6JgQpG7xWlH0nRrIRuhIQOyziMaaIiD+WXsFEwr ZtFxmrAUV7VFJ8DzhnePUypXG/nRE1PpJ0HiSl+y2KFO51bdkJ1qEvbBxw7BzIcmFTHp VA9G20YiOhAXV9aawcGV75yZEB2qJ5o/mKTMqQ3wo21BUU6k+JCJEy1dgtkWDe1ug2dq 4SJVjR1GpngelWHYSKcdYFiB/jithCKp6BvjMss10NOI1WZJQLnDUf8LOcx8BUMStOZE pKccMdImoWnpzeotqWQT7XHA2JevufCkYoeGcu0TpbpqNH19vCfALa4xwGRYkVsJNVsk KrgA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0eQBvdbE; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id y11-20020a17090a86cb00b00274274bf0ecsi5697617pjv.61.2023.10.16.04.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 04:54:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0eQBvdbE; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id ADCFF80A5313; Mon, 16 Oct 2023 04:53:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232955AbjJPLx5 (ORCPT + 99 others); Mon, 16 Oct 2023 07:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232764AbjJPLxy (ORCPT ); Mon, 16 Oct 2023 07:53:54 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2042.outbound.protection.outlook.com [40.107.102.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DD9B118; Mon, 16 Oct 2023 04:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n5CN1ZxpI+MrfKf75ATvqxNc3pBVZKPqEV0k47JRlguNoeL0f4HhR9Qk/Dr1xvC9EitCSfdv7psb4h0OXgLPLFGvL5pBA6mgn/YGbKs1okPDor2CoxVw0IV6YWrgWiaZ+T8lzeouH6pyvpBOo5XMjALLp7aNAh3HkU9xUkLwTBNMK7FjAz/kH09F8zUyGXWPCoDu3zgJYP/tJw3M7AES+eGrOYVgwogV8xCkFhuYn6JQlHLizpvQYldF+n/KWxMIwFJ3eyasd2NiGYVM/6L4yJQ4QCCMwbTh3nrxK9hADJCQCmYxT6NrCnVSefuIhZLlUW/fW4XjBKWE2NHadP4L+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/OHgKUYFAZCONnATUVnBIwfZqzs8EaYMPwtwwWj6zPA=; b=Nv9XKqQrEI8C0pYLOaLvJMDsJA2dJulq/iZ9a8stITQykhTtWkJATUvA28UXno1EAwdhuGQ7z8LSUwJ2eU46SuBIguU1yglfRYQE2reh7dVj/dmzMfaukzM6QWDPoKT8gN9A9cf01teLd2i5ZxaYPNK+xTuLNqty5KftxktsG4LyUtMpEVpHm6bMp03bk5UfQoo4oHi6D+sGaTcta8pHSfmCy8/D/wHaGLHL1pTLt5UWEcby+maA4IKP8t9/6/R9z0GxZ2MCYznjzbqpXPWRhbBt1sCi4lttCRcbdiUaeTXTKsH2QMjAiOdrprETByHBk3kpIQQfHgeEuTh5i6bVOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/OHgKUYFAZCONnATUVnBIwfZqzs8EaYMPwtwwWj6zPA=; b=0eQBvdbEtgJNh4G0P1QDKsH9akDx+vqB2rT0NUSb0Tw71a0yNWIPJdHkK8xUlwCMJLtIzLseJKvxelamt1MTc+YMVYcOmcLQFKjz8tswpHHRSOBqJ5S6hDHsuYFtbQLK/cVibkGzmLz5cE/bPbGSZdexjn4PeBu89Uh3Ufm3Hg4= Received: from SN6PR04CA0095.namprd04.prod.outlook.com (2603:10b6:805:f2::36) by CY8PR12MB7660.namprd12.prod.outlook.com (2603:10b6:930:84::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.34; Mon, 16 Oct 2023 11:53:48 +0000 Received: from SA2PEPF000015C8.namprd03.prod.outlook.com (2603:10b6:805:f2:cafe::da) by SN6PR04CA0095.outlook.office365.com (2603:10b6:805:f2::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.35 via Frontend Transport; Mon, 16 Oct 2023 11:53:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SA2PEPF000015C8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Mon, 16 Oct 2023 11:53:48 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 16 Oct 2023 06:53:47 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , , Subject: [PATCH RFC gmem v1 6/8] KVM: x86: Add KVM_X86_SNP_VM vm_type Date: Mon, 16 Oct 2023 06:50:26 -0500 Message-ID: <20231016115028.996656-7-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231016115028.996656-1-michael.roth@amd.com> References: <20231016115028.996656-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C8:EE_|CY8PR12MB7660:EE_ X-MS-Office365-Filtering-Correlation-Id: 3db7f415-47f2-4d5c-f397-08dbce3e8eb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j+OqCqSbLp/+f5t5QRtCPHeQtMatZSancDPNeZu1R3eqdDR5vxNvR3hEGhgmLTU2hJviSfx7RiLAm/klSI3W2aoEZCrI3dSgjV/koKuepCwa6YLRRjYsU2T16+Qgu+3WzLLP9wVxlZZBQDc6pLxCO4dQ+Hu+YH1j+ofKnrdokizvx3Y40OnRqXmXh6/6/UW36GRWYXY9M0LMoKCDZZE8gEzunw+LBQa2dCWZWGlaIeY6YRwhF+7IMIHaZiMzJVciDB6Hz+kZYZhiDjFJJiUjZi0YYMvFiWtS+py/8MdtSt3spGHcpUHm8EBUc8gzbf1SrIt6cYpMwrEPrrcvuuJTTTmj2a9lMSa/4XtAsrXpmOaJH44i3Deps4E092OTOwc7wrf8i8H8eo78my3/nmSYqYi3BwimCysaVsBzOMya4B9ulogS5I+xrSKDW4DUhXk2SvUNq6ykbq3UOjoPztFyHG0gcmcs+JiXDYGxuPSPCMXpIZmd2g0QYfxb7aoG8qOikVQuRMo5gex2rbqSUis5uTkfgnmvrBoofubOclWE3VdnezIrGmFig0O65edHe7Gvs9vRkwpD1H5P5UFzQSPH/p3ob03CxkakC+OAWmU0LzmTchsXKijIJOrF99iejpHIaOjhjZiS8x3+pYQGWJrtu0I8r6c8agLYi6yNAoA//j6fcMDoCJtTVwy4WNPibvHCF5a8/bFIC5KBMzn7eUcW3QkbDJjEugmTT2T/g6+eYHYsui+Z7ZFklB8ihVFe96gpFuXW1gSx/u4d1P+Ilcw3Fw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(136003)(39860400002)(346002)(376002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(82310400011)(36840700001)(40470700004)(46966006)(40480700001)(40460700003)(6666004)(478600001)(36860700001)(47076005)(86362001)(36756003)(81166007)(356005)(82740400003)(2906002)(7416002)(83380400001)(16526019)(426003)(336012)(26005)(2616005)(1076003)(70586007)(5660300002)(41300700001)(6916009)(54906003)(8936002)(4326008)(8676002)(316002)(44832011)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 11:53:48.0055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3db7f415-47f2-4d5c-f397-08dbce3e8eb8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7660 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 16 Oct 2023 04:53:59 -0700 (PDT) In some cases, such as detecting whether a page fault should be handled as a private fault or not, KVM will need to handle things differently versus the existing KVM_X86_PROTECTED_VM type. Add a new KVM_X86_SNP_VM to allow for this, along with a helper to query the vm_type. Signed-off-by: Michael Roth --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/include/uapi/asm/kvm.h | 1 + arch/x86/kvm/x86.c | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index dbec74783f48..cdc235277a6f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -2089,6 +2089,8 @@ void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level, #define kvm_arch_has_private_mem(kvm) false #endif +bool kvm_is_vm_type(struct kvm *kvm, unsigned long type); + static inline u16 kvm_read_ldt(void) { u16 ldt; diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h index a448d0964fc0..57e4ba484aa2 100644 --- a/arch/x86/include/uapi/asm/kvm.h +++ b/arch/x86/include/uapi/asm/kvm.h @@ -564,5 +564,6 @@ struct kvm_pmu_event_filter { #define KVM_X86_DEFAULT_VM 0 #define KVM_X86_SW_PROTECTED_VM 1 +#define KVM_X86_SNP_VM 3 #endif /* _ASM_X86_KVM_H */ diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0e95c3a95e59..12f9e99c7ad0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4444,10 +4444,16 @@ static int kvm_ioctl_get_supported_hv_cpuid(struct kvm_vcpu *vcpu, static bool kvm_is_vm_type_supported(unsigned long type) { return type == KVM_X86_DEFAULT_VM || - (type == KVM_X86_SW_PROTECTED_VM && + ((type == KVM_X86_SW_PROTECTED_VM || + type == KVM_X86_SNP_VM) && IS_ENABLED(CONFIG_KVM_SW_PROTECTED_VM) && tdp_enabled); } +bool kvm_is_vm_type(struct kvm *kvm, unsigned long type) +{ + return kvm->arch.vm_type == type; +} + int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) { int r = 0; -- 2.25.1