Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp632467lqo; Thu, 16 May 2024 17:38:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjkWWNcmcVHwr82SIDQ6sSGsQMeLSu2HE1laODG1ATjkiHlaGjU4DsbHyZUXINL6nOLOTCzMZtn/o8bxz8PU/NsRciv9W0H8vj1BVRMQ== X-Google-Smtp-Source: AGHT+IH4Qh4lNfVyAfmbv2VZ+jrNO5BMM3OfNwS1JgoIEu1Km03SKwoRnaRoJjAfIl4AyD2FZEmu X-Received: by 2002:a50:9345:0:b0:572:a6ec:2396 with SMTP id 4fb4d7f45d1cf-5734d704e0emr21681263a12.35.1715906335468; Thu, 16 May 2024 17:38:55 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c3627ebsi9381167a12.485.2024.05.16.17.38.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 17:38:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181658-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=Wts9TVLd; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-181658-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181658-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.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 12B7C1F229FC for ; Fri, 17 May 2024 00:38:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09513D266; Fri, 17 May 2024 00:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Wts9TVLd" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 F21BFBA29; Fri, 17 May 2024 00:38:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.10 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715906286; cv=fail; b=mzaqZm761kZh/okzJsX+b3zZpO7vBTgDEg0GKWZ2yRfd38zd6nahGiKQfzK+toGaVgURTAqgTGe+t17huCsml6bNcWJtD1jBzSAGb2At14uoqPjBJ2rt5o8Mu97U99H3QHGzj5qDR2A1kmIsGsXGmnK/oswy+na4nTUFj+mT2ys= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715906286; c=relaxed/simple; bh=ZPcmVgUVDKN7utQuNDX809PMV/Et3KbLjsv/5QHLI7A=; h=Message-ID:Date:Subject:To:CC:References:From:In-Reply-To: Content-Type:MIME-Version; b=AX5rcMuomnPULVENxCtb2y9aaftHf4YmY3qx+9Q1Hu9rGkqNDU+OUGs+LXkBRDBbjLU4Q3LFMV6bVJjGUVO3ktbpP5to5JwYLiMoi3+YOCUrKFbyS9KukIE6EIcesXSLxGtLGOPn3QBMvCvkGQSOPo70RxianbgYyhTPZMmFVPY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Wts9TVLd; arc=fail smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715906286; x=1747442286; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=ZPcmVgUVDKN7utQuNDX809PMV/Et3KbLjsv/5QHLI7A=; b=Wts9TVLd6iJOrKRLpQONd1pwTVfH6Jgme4Ayo1aSd2D2CIInb9FFbKGD Z3gFpkNoPo6z7fq8sQ/+t3Dx4dB2P5ymJdGs+IZXiyZmY1BRvVpp1K6Q5 uz5ks4QPz0zbI7nL0tTGQISPCYC044r8Va66KD1lVmjDPMeslQNEkb34I iF9CFJPAYSRmalJoQQgcz6H/SSlQ0lXaGZLYN3R3Fkq0PwIDYsRl+EXBC fW3PD0dB+xgJmeoxsVCejcx9wirlAY7KF07RMic3nzauklH/rFpjd9RLS hcfLYqQJeo3vSBAKcAFNMy6eUvKHq4FvlUbd5t7UanqPutd5Jt09G4DLi Q==; X-CSE-ConnectionGUID: DFyPM1ZtSoiQijImzsb3MA== X-CSE-MsgGUID: cR8DwOTfQ/WQf9odHpf64g== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="29563449" X-IronPort-AV: E=Sophos;i="6.08,166,1712646000"; d="scan'208";a="29563449" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2024 17:38:05 -0700 X-CSE-ConnectionGUID: 0d7GVhbfTZ2hYn+Mo0Pldg== X-CSE-MsgGUID: YC05Z50mQ3eIpjzSbyhmAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,166,1712646000"; d="scan'208";a="36173779" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmviesa004.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 16 May 2024 17:38:04 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 16 May 2024 17:38:03 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 16 May 2024 17:38:03 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 16 May 2024 17:38:03 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.40) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 16 May 2024 17:38:02 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YAqidoq8ZYWmca2k4ZyR+uZq7ShCR63OHhRQjLrqRkWtEC98SuBmAtTsIJsibePa7GOKbNmsJ9Q12MWugdyBBkddAM0Q2W9rZQxG7gwqOAimKVMDN8eVzFlM32gvp1P3ldZRL4QXaWPrO4jAqJ8qpfdhElck8Te3dzp0acsX4qlR3bHEsqxyXd4BCrauKhEbuR1OgyS/3Pvxh0cNtGBNq+GpeIp1oAO1z+KioUJ7/wCrPNKqpadJcBDNzghzzpdtOLQz6wNSHa1qv+tdvz5gyEHQYf207b+7H7O76mv241bypQ2KDnkppynxQRGoWRBoPgGOAmrVXPsBBUcVx2RKjA== 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=kwQj/8Tcxf7LQNkm5ef7wEzGDD3Euvk4WTVCeXL5Y04=; b=ejQGlojfeBdofJ3NTY/ckAtDb612rVaPbh341uNcAm4iogISqLZsQReCsQXhoSapfMiJLJeSzqAa4pYeeNpvXrjffTJpeQR96tX5KNROysjnz3lxNk26IZXK9TnRaIL9rBbrkgawIBp8V92W+K5rKyMKsxsFSX3N4h+2DgUBzsSXiAHSfBzHI5zwj7ripz47jPzSgRkMOOxMmD5Q7vUOhhkneuy1sYqACFyEIC8s8R6V2eED/nhpVANF/tQ6pfY4SrkQgSbfeX3PXhgkwBQgrvA5cj7B29Lf4cUBqLfX7bEgLhZ+QDq4L5Vc7Ja5ZCrW+VDYnoXg6HqMKXnOtt2zaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BL1PR11MB5978.namprd11.prod.outlook.com (2603:10b6:208:385::18) by MW4PR11MB6763.namprd11.prod.outlook.com (2603:10b6:303:20b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Fri, 17 May 2024 00:38:00 +0000 Received: from BL1PR11MB5978.namprd11.prod.outlook.com ([fe80::fdb:309:3df9:a06b]) by BL1PR11MB5978.namprd11.prod.outlook.com ([fe80::fdb:309:3df9:a06b%4]) with mapi id 15.20.7587.028; Fri, 17 May 2024 00:38:00 +0000 Message-ID: Date: Fri, 17 May 2024 12:37:49 +1200 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 04/16] KVM: x86/mmu: Add address conversion functions for TDX shared bit of GPA To: "Edgecombe, Rick P" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "seanjc@google.com" CC: "Zhao, Yan Y" , "sagis@google.com" , "linux-kernel@vger.kernel.org" , "Aktas, Erdem" , "isaku.yamahata@gmail.com" , "dmatlack@google.com" References: <20240515005952.3410568-1-rick.p.edgecombe@intel.com> <20240515005952.3410568-5-rick.p.edgecombe@intel.com> <9f315b56-7da8-428d-bc19-224e19f557e0@intel.com> <307f2360707e5c7377a898b544fabc7d72421572.camel@intel.com> <465b8cb0-4ce1-4c9b-8c31-64e4a503e5f2@intel.com> <4e0968ae-11db-426a-b3a4-afbd4b8e9a49@intel.com> <0a168cbcd8e500452f3b6603cc53d088b5073535.camel@intel.com> <6df62046-aa3b-42bd-b5d6-e44349332c73@intel.com> <1270d9237ba8891098fb52f7abe61b0f5d02c8ad.camel@intel.com> <0a1afee57c955775bef99d6cf34fd70a18edb869.camel@intel.com> <9556a9a426af155ee12533166ed3b8ee86fa88fe.camel@intel.com> Content-Language: en-US From: "Huang, Kai" In-Reply-To: <9556a9a426af155ee12533166ed3b8ee86fa88fe.camel@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MW4PR03CA0140.namprd03.prod.outlook.com (2603:10b6:303:8c::25) To BL1PR11MB5978.namprd11.prod.outlook.com (2603:10b6:208:385::18) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL1PR11MB5978:EE_|MW4PR11MB6763:EE_ X-MS-Office365-Filtering-Correlation-Id: cccbfab0-f0bb-4305-1697-08dc76099a7e X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-A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ekUrT0hjTFRzMjFpeWN2d3QxSEFwWG9oZnVnPT0=?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR11MB5978.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Y3h6VmhNWk55ZHplcm5FN1UvQkRsYVRpaW1VZWZmR1haa2FQTk9PSW0xYXl5?= =?utf-8?B?U2w0Mko0anRXR0V4bTdNSW84SnhjMHVROFpoKzdxVFRqVVdsZ2h0VXlNK091?= =?utf-8?B?M3lYQXVhY25ERThhVzloYUQ2WWExeENzNFhJd1N6N3cxVUJMamtVRUlCVzg3?= =?utf-8?B?TTdPSVJGdk1CQjV2MmpBYWlNQnducjBPMWJDVTdvQll6ZUg1WnJiQjd2VmI5?= =?utf-8?B?SEJ0cUdOYjdybnNUd2tMaXlGc0JmeXB5WXIzQzQrOVdlZnRpRnA1UUc3QkE5?= =?utf-8?B?MFJLSHhjRW45UUp5RVA2U3NjeUN6Z2NwelJHWmpvWndtdEg3Y05nSFJ1OENM?= =?utf-8?B?NlVXWFk2RklHU25wa0hmcnZUa3M3QmNvRW9SYlV1STZPL2JIK0I2YzZJeDd0?= =?utf-8?B?TGt1MVVQV3ZzTG9Ib2NIeG1DQmRQTTZQaDJEc2hxYkd1dE5URHV2UHBOK2hS?= =?utf-8?B?TzBpeFZaSXBwQUFpSVFVdklOallXK0ZPSGsyS1M1WWVPSERFRWVSRG1HSVQ4?= =?utf-8?B?ejhlRkU3QTFzeE5mU0FLREZTNCt2VUoxcTJTQ3BGUzlha0ZTWmRrOGhSbWk3?= =?utf-8?B?RDgxWnJjRy84eDJEb0djaHg5cGluTURlT3ZYR3ZKREpDeEtaS1V4TE5ZbzRr?= =?utf-8?B?NWtJSENOVmRaQ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kox?= =?utf-8?B?NlhCaWpaOFJwbUNlZVcxMGh0ZDdOZjJPTnFScXk0V25BTjFNRHJzaCtIeXZp?= =?utf-8?B?THR4TFE0eWtERWFuYnhnNVRwRHkwZzdYMnBGR01EVVFRQi84YVR6RVBGS0NR?= =?utf-8?B?dGQzSjRMNmZsNDJjTktpRnR1bkJ1VWxrUHNMc2FOMlNSSWhmQkRXNGZvNFNM?= =?utf-8?B?YllzT3NFWGt6Smphc2VEUXZoVERjT1hYd3FKOVBNME9wMSs3K24xR3VFcG4v?= =?utf-8?B?USsvdkhSN1Vwb3JnelVYSGlBVXNNQkxEdFJkVmFleSs2YmpLdElUTW9VT3VF?= =?utf-8?B?U1lCYVhXM2d4aFBweWVHRFlWd0wxQ3FxNlo0UmQxT2J2SWlNQ21BejVZOUJR?= =?utf-8?B?ZVhQVG02VkxtL29zNGRGK0FLTGpBcHlsTUdvdnlhOXZwUTh2bmhtNEN0NDhF?= =?utf-8?B?bWRkUU0zcmdNMDVHeHRVNjQ5WFBtTFZ6bUtXZm9DaWhtSDB5bmJaVHdhV1hH?= =?utf-8?B?WGdBZ1hmSjJlOG5PYllwZTN1NmJrbWJTVzQxR1BXWmRUQ28wSzFvTW9pMHpH?= =?utf-8?Q?AmI5G2tcfGBKcpHqtH0GqvBDj?= X-MS-Exchange-CrossTenant-Network-Message-Id: cccbfab0-f0bb-4305-1697-08dc76099a7e X-MS-Exchange-CrossTenant-AuthSource: BL1PR11MB5978.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2024 00:37:59.9584 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ocFyCJdgOcgVzT9hO52lUo5+1KMvT3p1G241wkM2EcWUZvxheKcsr5d6Jd7rWmK2dgcr5FcQsKR4FzlV3JSSgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB6763 X-OriginatorOrg: intel.com On 17/05/2024 11:08 am, Edgecombe, Rick P wrote: > On Wed, 2024-05-15 at 18:20 -0700, Rick Edgecombe wrote: >> On Thu, 2024-05-16 at 13:04 +1200, Huang, Kai wrote: >>> >>> I really don't see difference between ... >>> >>>         is_private_mem(gpa) >>> >>> ... and >>> >>>         is_private_gpa(gpa) >>> >>> If it confuses me, it can confuses other people. >> >> Again, point taken. I'll try to think of a better name. Please share if you >> do. > > What about: > bool kvm_on_private_root(const struct kvm *kvm, gpa_t gpa); > > Since SNP doesn't have a private root, it can't get confused for SNP. For TDX > it's a little weirder. We usually want to know if the GPA is to the private > half. Whether it's on a separate root or not is not really important to the > callers. But they could infer that if it's on a private root it must be a > private GPA. > > > Otherwise: > bool kvm_is_private_gpa_bits(const struct kvm *kvm, gpa_t gpa); > > The bits indicates it's checking actual bits in the GPA and not the > private/shared state of the GFN. The kvm_on_private_root() is better to me, assuming this helper wants to achieve two goals: 1) whether a given GPA is private; 2) and when it is, whether to use private table; And AFAICT we still want this implementation: + gfn_t mask = kvm_gfn_shared_mask(kvm); + + return mask && !(gpa_to_gfn(gpa) & mask); What I don't quite like is we use ... !(gpa_to_gfn(gpa) & mask); .. to tell whether a GPA is private, because it is TDX specific logic cause it doesn't tell on SNP whether the GPA is private. But as you said it certainly makes sense to say "we won't use a private table for this GPA" when the VM doesn't have a private table at all. So it's also fine to me. But my question is "why we need this helper at all". As I expressed before, my concern is we already have too many mechanisms around private/shared memory/mapping, and I am wondering whether we can get rid of kvm_gfn_shared_mask() completely. E.g, why we cannot do: static bool kvm_use_private_root(struct kvm *kvm) { return kvm->arch.vm_type == VM_TYPE_TDX; } Or, static bool kvm_use_private_root(struct kvm *kvm) { return kvm->arch.use_private_root; } Or, assuming we would love to keep the kvm_gfn_shared_mask(): static bool kvm_use_private_root(struct kvm *kvm) { return !!kvm_gfn_shared_mask(kvm); } And then: In fault handler: if (fault->is_private && kvm_use_private_root(kvm)) // use private root else // use shared/normal root When you zap: bool private_gpa = kvm_mem_is_private(kvm, gfn); if (private_gpa && kvm_use_private_root(kvm)) // zap private root else // zap shared/normal root. The benefit of this is we can clearly split the logic of: 1) whether a GPN is private, and 2) whether to use private table for private GFN But it's certainly possible that I am missing something, though. Do you see any problem of above? Again, my main concern is whether we should just get rid of the kvm_gfn_shared_mask() completely (so we won't be able to abuse to use it) due to we already having so many mechanisms around private/shared memory/mapping here. But I also understand we anyway will need to add the shared bit back when we setup page table or teardown of it, but for this purpose we can also use: kvm_x86_ops->get_shared_gfn_mask(kvm) So to me the kvm_shared_gfn_mask() is at least not mandatory. Anyway, it's not a very strong opinion from me that we should remove the kvm_shared_gfn_mask(), assuming we won't abuse to use it just for convenience in common code. I hope I have expressed my view clearly. And consider this as just my 2 cents.