Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1688376pxj; Wed, 19 May 2021 11:30:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTGYjcsCN/4Mxnihf1VO14iPAn3sSN7YULJuqDcnvmndw4XxaLxmCdB4/VAkQfFT/yJu5S X-Received: by 2002:a50:ff15:: with SMTP id a21mr405446edu.103.1621449009356; Wed, 19 May 2021 11:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621449009; cv=none; d=google.com; s=arc-20160816; b=xCDhbY1Jy3brbyRw69IRus2xBAZouJsU3QhzQJZwF9JC5I1fhOnJDjdrrPIlauWw4f pwPmZRpkPOzySAjOaM4HNLU8SzPrGLe5bHfDTydggfCXhErn/L5+0V88JS0Bk2hRDmnL C43GrQO14QZXxhHPx8mZFn/WvOP9LVFbLW9Z/PL05Ee+rMEPS0TqwZZ4OUpq6skAO8BF J8NFgBMvnKQxFZvJdyCk6/GnV1asDBUi4Dk/b8NwjluHRbhksohGzOiTUlDj3zMYk32e EyMjNrEOerSMZsM+rR8O7MVqmpG3U4f7LbhU17Jy/b8MfQKMMBj+8SvgwfoqNgEK/MAQ phlg== ARC-Message-Signature: i=1; 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=QzgFyTrmOOgigcmGYYikGxaNK4XgtChwrAVVbZtLX9o=; b=mF9RFygSaWREfoLZrzQCA18p5riropWOvzXt/KrnXFUAdcaZG0uMwgkNYOyEH2jlOD xodJ5aaJxLM+A2dW6ymmqVSbxqcY9QvsHJMjywGXm1eGXhMWv8udXFTbYSpQDKXah7ks ibCuWsTBrVaesDSOG0XKUIQIUPtN4xY840lEPR/qP6FeUuHkOOse+gNfQ+Frm3RLzzGJ W33ubnd/HNg7NB8XU/Gn6FpU38U3uFcyEiSyzfIwF9AgxxVgH/KtLUsisKmJ/v9+mhE3 DPbp28ki0GKanpB96OcDdVgIk0OFeoJzAOCtsX1FaDTVOPkQKrhm9cNBAyuwQMPXBJm8 NMrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ggkSLbsB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qp22si364721ejb.190.2021.05.19.11.29.45; Wed, 19 May 2021 11:30:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ggkSLbsB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349833AbhERShr (ORCPT + 99 others); Tue, 18 May 2021 14:37:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238176AbhERShq (ORCPT ); Tue, 18 May 2021 14:37:46 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44DCAC061573 for ; Tue, 18 May 2021 11:36:27 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id pi6-20020a17090b1e46b029015cec51d7cdso2028907pjb.5 for ; Tue, 18 May 2021 11:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QzgFyTrmOOgigcmGYYikGxaNK4XgtChwrAVVbZtLX9o=; b=ggkSLbsBMYtIslwifxZeAUmdD16hUHocnlMQWIpdEVZGLXBsbrg9XyWMm1RMQApdhq OtE+qX6+rClBVQHIXI2Oaa8qNKgYbSkAr1Iv2fQzivdHEKA1HxD3eMpzwhT3DEAbNb6K 3tX2KFT8rsc6iCheN4URUUa++15rMfQgRtN0g0lC9CRka4k8KAEyhmz4voa2BX+rRkuX oC9FRPzqxCktWi6xIITPBU0J/decMV562Hj3rfHapwl6mg6FGK1GUKBCjMBFd1k/seoo hB/Ki3YKwmMlE1Adik3esKvfZWCxQVbj4mEEEQq3i9bWMSl+H/6M/XR60lLL0kWRY3sa gdKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QzgFyTrmOOgigcmGYYikGxaNK4XgtChwrAVVbZtLX9o=; b=Mdm6uB05Q+oee5cLqs6/AMyPPz2C7hT2gtxYDbyR7MK7Z7YrFaqI4VSSzrxM5BA1Gs 38Wgzc/R7dwPV6n56dwY2uOobiwdWltMnL/xYG2VAjHYZwvqG2xCkwB4ZUIB9cYiJySp IBaJszcUb6aAQKOOIkTBYnxqov8fL2ZpQDxtbvdulnwAFSTwD959thoIxTzRo6BJst/Y voFNw6bTWPUz2myAgo7A4InkbFelG14pOqF998EoUtbma2SbIN7VnxELroM7J9eIIA6h 7AKgx6X9cUzO0DD0nxtjQu/sKyzlfoqDXbi5yvKeUpipDY7vvh4tRtzgSIvtckTZYZCU Ub2w== X-Gm-Message-State: AOAM533kg88E4rN8PdmyTRhgvkXrIfX0j//vbVKqH0dbGPKhjePfD3pn MJn0FBm7mn6CebybNatxU1c3iA== X-Received: by 2002:a17:902:a60f:b029:f0:c3c8:2e20 with SMTP id u15-20020a170902a60fb02900f0c3c82e20mr6060286plq.51.1621362986492; Tue, 18 May 2021 11:36:26 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id h18sm3517487pfr.49.2021.05.18.11.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 11:36:26 -0700 (PDT) Date: Tue, 18 May 2021 18:36:22 +0000 From: Sean Christopherson To: Dave Hansen Cc: Andi Kleen , Kuppuswamy Sathyanarayanan , Peter Zijlstra , Andy Lutomirski , Tony Luck , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Dan Williams , Raj Ashok , linux-kernel@vger.kernel.org Subject: Re: [RFC v2-fix 1/1] x86/tdx: Handle in-kernel MMIO Message-ID: References: <3e9a26c3-8eee-88f5-f8e2-8a2dd2c028ea@intel.com> <20210518004807.258503-1-sathyanarayanan.kuppuswamy@linux.intel.com> <36cd2665-6d8b-9c0b-eec1-25152dcca2a3@intel.com> <43e583a3-ee2b-52d8-5275-e26a6609c126@linux.intel.com> <8fb0e52c-ed0a-2185-585a-27007c27ed56@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 18, 2021, Dave Hansen wrote: > On 5/18/21 10:21 AM, Andi Kleen wrote: > > Besides instruction decoding works fine for all the existing > > hypervisors. All we really want to do is to do the same thing as KVM > > would do. > > Dumb question of the day: If you want to do the same thing that KVM > does, why don't you share more code with KVM? Wouldn't you, for > instance, need to crack the same instruction opcodes? Pulling in all pf KVM's emulator is a bad idea from a security perspective. That could be mitigated to some extent by teaching the emulator to emulate only select instructions, but it'd still be much higher risk than a barebones guest-specific implementations. Because old Intel CPUs don't support unrestricted guest, the set of instructions that KVM _can_ emulate in total is far, far larger than what is needed for MMIO. Allowed instructions aside, KVM needs to handle a large number things a TDX/SEV guest does not, e.g. segmentation, CPUID model, A/D bit updates, and so on and so forth. Refactoring KVM's emulator would also be a monumental task.