Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1614222lkv; Wed, 19 May 2021 14:05:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI2/GmW83iOLOrlgTqvPCRIw/woFuaatRkDt0Fo5LqrnWI8Zjxj9S0GZ+08WAu24Hq0eIb X-Received: by 2002:a17:907:770a:: with SMTP id kw10mr1092512ejc.213.1621458356544; Wed, 19 May 2021 14:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621458356; cv=none; d=google.com; s=arc-20160816; b=wZOp4inlr8TeTdibCnYkrBFXnHf30XTbDtZaAbsF1mdgv8wWhtnI7t0mRaBby+WAwa p+gbfKPcG6gxHpayr6YXf+yBzcRKQraGg796er/D2UypSSZHsGN6KZO/F/VzOCnrtpPX 1u4E8ijkbBC5xpw7mMoNK4DqNFitX/1BO7kHWWFCZ3APIk06AYWRskaa240Ms/+kKGmX ZfGXffUftOU9OlQMxRmMB7PGYSHEILgahoLC4bxxfAonbhDmSNjyYs7kjolttTyV2UJM nfNkOmY88E3wi2VBRDz6CAPqb/Fw+R2NN51hqgA4ZNp7GNJds5kOwKzTWoyP+qhp+Aff +q5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=tANzp5vXv/Tcp7AKPBViyrAW0YU6eA4kj4/PsKyR2kc=; b=iqQsh0bmrQIkP8LFcy+B1y3yALz7MKMExQXFZogl885H2ZmcLtEdRXcS06EkUISvBZ 3C2RBgpQcm5OoZ2pCL71yhxSOmAqEvtAMg7qwBdf0dfgr5hfvfOrwImXHjsxhwT1ClWM mCB6TLagaSVjA/OZ/6ud081Nju3Z5md06eL8twMtRCuDFqPvr1NIOHxMwt6I9D1pcYD5 4M1xHaPtvVfecvoOvGxOgt8g/rMBe0rKbmzYkDW+t95pP/Xv564alpGyBsBDFwtDtEiw QzAK51sBNFmCvdp27gKRLAAFneXJRM7JGdlX0xSHJ6EtBMnNvNqVH0erEmkbwocqJvzJ 6KPQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si266729edv.421.2021.05.19.14.05.32; Wed, 19 May 2021 14:05:56 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240494AbhERUWa (ORCPT + 99 others); Tue, 18 May 2021 16:22:30 -0400 Received: from mga12.intel.com ([192.55.52.136]:16598 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236196AbhERUW3 (ORCPT ); Tue, 18 May 2021 16:22:29 -0400 IronPort-SDR: L7L+9drAfoa2hq8CVm9MEteJnHEedOcnLGJpSGYLdlKdb0Gk6sbeHB/M7N8tJtiXkF0qm/991l dhSmmaIifQNA== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="180413889" X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="180413889" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 13:20:51 -0700 IronPort-SDR: 1s+fv5Q7+YbZ5bkbCM73lxZjqaM9gP9ICHbVeEH2kjoelySdebsULAN4dv8/hprsFScixOL1Ob xCZHXkM0H6XA== X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="439616846" Received: from akleen-mobl1.amr.corp.intel.com (HELO [10.209.65.183]) ([10.209.65.183]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 13:20:50 -0700 Subject: Re: [RFC v2-fix 1/1] x86/tdx: Handle in-kernel MMIO To: Dave Hansen , Sean Christopherson Cc: Kuppuswamy Sathyanarayanan , Peter Zijlstra , Andy Lutomirski , Tony Luck , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Dan Williams , Raj Ashok , linux-kernel@vger.kernel.org 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> From: Andi Kleen Message-ID: Date: Tue, 18 May 2021 13:20:48 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/18/2021 10:46 AM, 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? We're talking about ~60 lines of codes that calls an established standard library. https://github.com/intel/tdx/blob/8c20c364d1f52e432181d142054b1c2efa0ae6d3/arch/x86/kernel/tdx.c#L490 You're proposing a gigantic refactoring to avoid 60 lines of straight forward code. That's not a practical proposal. > > I'd feel a lot better about this if you said: > > Listen, this doesn't work for everything. But, it will run > every single driver as a TDX guest that KVM can handle as a > host. So, if the TDX code is broken, so is the KVM host code. I don't really know what problem you're trying to solve here. We only have a small number of drivers and we tested them and they work fine. There are special macros that limit the number of instructions. If there are ever more instructions and the macros break somehow we'll add them. There will be a clean error if it ever happens. We're not trying to solve hypothetical problems here. -Andi