Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp262411rwl; Wed, 4 Jan 2023 18:59:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXvOrdHd9ITzvu4zMpFx9GG9ON/R40SHLT73QyPPMiI4rSMQpCnppGbbNj3H+Li62k+8WJli X-Received: by 2002:a05:6a00:72a:b0:57d:56f1:6ae7 with SMTP id 10-20020a056a00072a00b0057d56f16ae7mr43878139pfm.33.1672887567272; Wed, 04 Jan 2023 18:59:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672887567; cv=pass; d=google.com; s=arc-20160816; b=zBndX2qVYFs+SotHz1pu2oRrx+vC1LHwX/LJDWA0Qc83XjHCmhvLQUaUt6G50y6J7Z JneapU4Z+62WZbbtSBqk5NuawohwotunbmexmECgtrHkxogq8YVc1HUsIOxP1pwvl6aD Z1hdY0Ijl70ESOgjf0KDF4KxuCy2+H745CE+jPX0H+R97i03jPTtHTjFU+szX0Zaj6Mi JXplxZesJhkjeu3XLjfmUaPrlUjWfLkqg71wJR6Qv68U4DUXzqblY6TVjbrSRNcuBYeF T/se6x1umVR/gFmUSCV25a1cQlKDQTi0IujGZIsQPTnTUXEG64DqBSvvdcK3zmQfpaYD K33w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ugtSNyt+nUXlVfWzk5XZaVZAFZPpNa20m9RhqH2gMgE=; b=pOB1QBp8JGfZdUPJguC+GNVJsIB0REkrmpNRM/xSdJpq4qdQPp8Tc11vBIKRKgCWY1 plL4reKr4Pl51PSkV/20PtIepB8zlSTBX/L1NyLuz3UZROVEiR1a3CELE4tnwacVfmtu 9qtW3cPF5rdY8AmKYybcoPPUc7LPVbimpy0dAtJ2j1eXvbJHtnP9F6RYf7yquHtE55tM iOszCQ/kqkzQxesz4YHfylv0F0E56Ak2hYe0aKlg0lwUIWJoOBkbZGfq9rQaFxrEOIn1 HrDtlBZchqDBZchsu7jvcg+tG9n0Im8Z1vM+fqsytIaiYe2CWcbudBvm06UavfUhGTZs /TVQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lhD6g99o; 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 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a056a00229400b00580f7f384b5si18654938pfe.245.2023.01.04.18.59.11; Wed, 04 Jan 2023 18:59:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lhD6g99o; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229810AbjAEC6h (ORCPT + 99 others); Wed, 4 Jan 2023 21:58:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbjAEC6a (ORCPT ); Wed, 4 Jan 2023 21:58:30 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2043.outbound.protection.outlook.com [40.107.243.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 394029FFF; Wed, 4 Jan 2023 18:58:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nduR79k77Wpos/VAAYHoAvJ/+qLSQTuyGYledcPxkH2QyKTmkgQZVoALnh8O0BlG5+xTrKBQkWuJ25CIP0VPsxsRtnyqjKB/6y7xRTlpwvj9EZfiQnET9wTudrIIDCl3C8pv/P6kIkRZnJ+wdna6+sw2OH7dvhtS0GnOs3egTZcdbIo3hUu0aVHqSrHuen5byJpaHYb/7f7ygNbGkeOk6WoQ64lH9+cTsHrP2QfgH358uL6BqgYMvBGKSKwXZyZZtIIkOLs+M0mrP82alVfylwumMetF7EwOvYQ+LjD+RwTTN+sH7ghE4PiiIGrawoovNrgV/PXyOVJr04COzxG7eQ== 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=ugtSNyt+nUXlVfWzk5XZaVZAFZPpNa20m9RhqH2gMgE=; b=KVHpWV5jCb+NAWb/b723PycERWMb7PWYSkGOI1WCu9cuFVLsIQWgqmhIAXBK5RwoKiKlrORpFMBkjIkOG262eXFmXD+l5W1t4v07V/8okQ+Dx5xblCq10gZKvAY2EsS0n0KE/b9MC4z7ZqJcuBmL/ILm/9BtW+MrD2s/VRxM4TgKxj44tkgdGW8YkgUfSk7qUjEkLSrSKKvnB178mNi27l77llASP1yd/nkqmRImAfJmHS7Ak5cvqOD2onsCIpRKrKntsEnjZOamwN+pJ2NdatP4JEffjNIJSVOAquL8kdbzhmwYUFzlikt6ipIG8UM8O8XPTSPRRoexS+EGcuahOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=ugtSNyt+nUXlVfWzk5XZaVZAFZPpNa20m9RhqH2gMgE=; b=lhD6g99oAuFo2hrNsUo4rB6taBUD6LgFEfH+tmWxbAaksdBy5YkwCiR/m8BP9lHIlpTgN+WBwHCFCruMscuJV1QnVTCOA4J32R+XHaLNFZQH0ZQsPT5NHQWLSrZ93U/BhpnNEHAXBdyH8EVCrxQl2YqASxRDVn03RbkdfjBDUHU= Received: from DM6PR21CA0008.namprd21.prod.outlook.com (2603:10b6:5:174::18) by DM4PR12MB5748.namprd12.prod.outlook.com (2603:10b6:8:5f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 02:58:27 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:5:174:cafe::4a) by DM6PR21CA0008.outlook.office365.com (2603:10b6:5:174::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.6 via Frontend Transport; Thu, 5 Jan 2023 02:58:27 +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 DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5966.17 via Frontend Transport; Thu, 5 Jan 2023 02:58:27 +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.2375.34; Wed, 4 Jan 2023 20:58:26 -0600 Date: Wed, 4 Jan 2023 11:56:32 -0600 From: Michael Roth To: Jarkko Sakkinen CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH RFC v7 02/64] KVM: x86: Add KVM_CAP_UNMAPPED_PRIVATE_MEMORY Message-ID: <20230104175632.mqmg4xybbe7vzies@amd.com> References: <20221214194056.161492-1-michael.roth@amd.com> <20221214194056.161492-3-michael.roth@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: 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: DM6NAM11FT054:EE_|DM4PR12MB5748:EE_ X-MS-Office365-Filtering-Correlation-Id: 34744ed2-4ee2-42f1-fdbc-08daeec8b7d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uP94FJYLNcJRqz5NBffyRbBr9rBJ8sP1dEd4YohRg2C6ZG4h+PitSkFgpA4BvkIc2W9E1KK+qwuvcRNfZ7P5zi4hnwT5Acw8Sw3cYKsL5cGzNwDMBUS60z6OEZmUB3dmcgXtdUCQ7kg3wZrtRqjiszD3JyQC9fRoS/rGZH+J/iWoQp0JwV8acMmMYjpj6SvaUQNErr6/kItjyurXYzt1GmCFrw3jWqU7Gk5470AQTJ/Q8mOC7rz1S/o2jTeS7JztPFQ4KfO5U63JLyBLyszhK7EB2+q02AOVr2tq1mNbK8cqDeuZfpZ1ezbCph8wH30gw+Ylg8GCzUzEyFugvD4glZEafPWJ7N1IHWXzjzBLLqRRA8pG8RoJEdJYi5vijLOh17aeWcmtwnORDWpq2EadtvN8/M/rB9ZCHL+G0xW8Mo5dM9jEh+jNbRMFsc9vLFU8GDgPIavUYg2Vz0yOyIWZYIHCK6/RJR7AzeMpGBUPfgLEBxk9n+harhn29i4tLQpkrwSX1MbGOJFEMlVp0NxjLz3Y65eYXhaySwJtW5QTZcu7v5Obj+MH8rDioJUuQOp/1gLgbqSZAZyV8g/EO71Wc8yEdlZ/bUhdWZkeIX3nCoaNozcfBs3ZObX93fisrA+zE1VUlKHcGUtMQi6EQOzol8lKSvE7h+tdSWja0bFKJh3KuCJXbCfRPy5RVSqNpDHFogDJOfAO2m+BRw9aD5gjgUQMvqm1ftXCO4++NDTm6Q8= 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:(13230022)(4636009)(39860400002)(136003)(346002)(396003)(376002)(451199015)(46966006)(36840700001)(40470700004)(426003)(47076005)(16526019)(26005)(82310400005)(1076003)(2616005)(83380400001)(336012)(186003)(6666004)(40480700001)(40460700003)(36860700001)(86362001)(36756003)(356005)(82740400003)(81166007)(4326008)(8676002)(8936002)(41300700001)(66899015)(2906002)(5660300002)(7406005)(7416002)(44832011)(478600001)(70586007)(316002)(70206006)(6916009)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 02:58:27.0755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34744ed2-4ee2-42f1-fdbc-08daeec8b7d6 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: DM6NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5748 X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Jan 04, 2023 at 12:03:44PM +0000, Jarkko Sakkinen wrote: > On Wed, Dec 14, 2022 at 01:39:54PM -0600, Michael Roth wrote: > > This mainly indicates to KVM that it should expect all private guest > > memory to be backed by private memslots. Ideally this would work > > similarly for others archs, give or take a few additional flags, but > > for now it's a simple boolean indicator for x86. > > > > Signed-off-by: Michael Roth > > --- > > arch/x86/include/asm/kvm_host.h | 3 +++ > > arch/x86/kvm/x86.c | 10 ++++++++++ > > include/uapi/linux/kvm.h | 1 + > > 3 files changed, 14 insertions(+) > > > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > > index 27ef31133352..2b6244525107 100644 > > --- a/arch/x86/include/asm/kvm_host.h > > +++ b/arch/x86/include/asm/kvm_host.h > > @@ -1438,6 +1438,9 @@ struct kvm_arch { > > */ > > #define SPLIT_DESC_CACHE_MIN_NR_OBJECTS (SPTE_ENT_PER_PAGE + 1) > > struct kvm_mmu_memory_cache split_desc_cache; > > + > > + /* Use/enforce unmapped private memory. */ > > + bool upm_mode; > > }; > > > > struct kvm_vm_stat { > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index c67e22f3e2ee..99ecf99bc4d2 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -4421,6 +4421,11 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) > > case KVM_CAP_EXIT_HYPERCALL: > > r = KVM_EXIT_HYPERCALL_VALID_MASK; > > break; > > +#ifdef CONFIG_HAVE_KVM_MEMORY_ATTRIBUTES > > + case KVM_CAP_UNMAPPED_PRIVATE_MEM: > > + r = 1; > > + break; > > +#endif > > case KVM_CAP_SET_GUEST_DEBUG2: > > return KVM_GUESTDBG_VALID_MASK; > > #ifdef CONFIG_KVM_XEN > > @@ -6382,6 +6387,10 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, > > } > > mutex_unlock(&kvm->lock); > > break; > > + case KVM_CAP_UNMAPPED_PRIVATE_MEM: > > + kvm->arch.upm_mode = true; > > + r = 0; > > + break; > > default: > > r = -EINVAL; > > break; > > @@ -12128,6 +12137,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) > > kvm->arch.default_tsc_khz = max_tsc_khz ? : tsc_khz; > > kvm->arch.guest_can_read_msr_platform_info = true; > > kvm->arch.enable_pmu = enable_pmu; > > + kvm->arch.upm_mode = false; > > > > #if IS_ENABLED(CONFIG_HYPERV) > > spin_lock_init(&kvm->arch.hv_root_tdp_lock); > > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > > index c7e9d375a902..cc9424ccf9b2 100644 > > --- a/include/uapi/linux/kvm.h > > +++ b/include/uapi/linux/kvm.h > > @@ -1219,6 +1219,7 @@ struct kvm_ppc_resize_hpt { > > #define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223 > > #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224 > > #define KVM_CAP_MEMORY_ATTRIBUTES 225 > > +#define KVM_CAP_UNMAPPED_PRIVATE_MEM 240 > > > > #ifdef KVM_CAP_IRQ_ROUTING > > > > -- > > 2.25.1 > > > > Why we want to carry non-UPM support still? For SNP, non-UPM support is no longer included in this patchset. However, this patchset also adds support for UPM-based SEV (for lazy-pinning support). So we still need a way to let userspace switch between those 2 modes. -Mike > > BR, Jarkko >