Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp377020lqt; Thu, 18 Apr 2024 20:01:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhNDpjDHtJ4tepflLERc3Xhz29Z5VyMXIdohd/55OyzKs8hPpj+CS1WIcYXk/7qOsige0tQ8TxrWo9iiTKbwSlucEK6X0u4RtWbPI0WQ== X-Google-Smtp-Source: AGHT+IGr+yHZBuOU5onrd8HGNpUytN8GF8sX3D8zyzFnAd3agMcPBsoWus8u5R1T+jtm8u4gtlGO X-Received: by 2002:a05:6a20:d81a:b0:1aa:583f:3ee1 with SMTP id iv26-20020a056a20d81a00b001aa583f3ee1mr1141376pzb.41.1713495683381; Thu, 18 Apr 2024 20:01:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713495683; cv=pass; d=google.com; s=arc-20160816; b=N9M2ryyKcFt3WJMxWSyH9TkxW8Y3D2lP6B8jqy802OFxbBWBesxlBLIqyiI808iHHn lxuBc6Rl4ic3wW+c7VOzQjyIek//rujUigYxz6GdqWyuSzIrc5NHcmp+8544i5xPgFTs 4mYvQaUX8rWM6aY4S8RMAbh6t4HA1l8Z9n3xrEH3TNXr/jlVNjO1/NUvtYcxrIN6yfZN wkgYRVjT/8iPrHVuteSpbC40ARb0b4eyCAlaYQiCFLsHthFy5vMvEMLB+b9Tp1U2fOvX 4uV0dhsMorqAyGlyBFUu8oqUlRFSazgWMkGkHp0PA2hhKcemOVFEILoqvTs9NIorXZVP z9eQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=x32/paVKKENqIK8S/wFxMyZZdAQ67r9i7M/SRp+ur1A=; fh=HQExPnJwyJBU3Yd7YR8BXwU+gT7yOczz6JhhKzE/xBY=; b=s6adfAFRuKhSisL9v/Ew5qES7NEeTLKAqIMTtadtqYsLhMoQMemOgumse3KZjfrJ9w lW0nH1tpXVc9Q0EZCPbaHPqXlhhB6OSYryRDr8vRJCJVVnjwAa0bln6Urr5Nfh68WHQc bJxZzQ+mSyZ+/1vMNYA5BFMWS85kllN0gCN6sBchda/oBgPuEXpLtP+D+AMwPgc1b2KE LgOhan5dn54mHbcjg4kfIG/+cZ+vhOeoVGr+eizE49+6Hdhzw1lxa6Dp0HFMyMi0LB77 QHQcO2Elg/99fIzRGZZFQgjP+kL1oV8RFAi2L+zXPowSmkILc8NnJjWViD3obucYejCW pcTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=expQ49LH; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-150909-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150909-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b2-20020a631b02000000b005c66a3f3f5bsi2337518pgb.745.2024.04.18.20.01.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 20:01:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150909-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=expQ49LH; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-150909-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150909-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D80EAB2223E for ; Fri, 19 Apr 2024 01:43:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31DE110F9; Fri, 19 Apr 2024 01:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="expQ49LH" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 DE38F1362; Fri, 19 Apr 2024 01:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713490977; cv=none; b=kjN7OMC6pnG6/WaKrltBxeNJLsP+lfgPRhcSr9CtD4h4BDVT8K6ehrujN72kBoIeexI1WccJWQujBzjLQ92iZnCtDWdR5pALM4TC22GKJp+Dq9QXeqwM0dUxd4y78AyG9wfzFBGCMrXbcJWP6bIHq/Pg7EbTeIa5ZbGCQL3NmaY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713490977; c=relaxed/simple; bh=cSZkElQuxZTV1/D8NzqIO8txy29Fe8ChfyA1kCtXJjc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=X9zz8RMue4jzCZAvLyo8wKmwISWshIM8POHkOvuriK2sb76HD//m1xlLsB26j4cbfa8aQ/YY/d9v/o5Amq1l9LS0w91ZGNlhPu1TsQQEx6E9cnoel7pSo/0RylqOesmmF/njz7qENCVJKt5cRbirVohG7B0MQgFAPcSzFjY8ZRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=expQ49LH; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713490976; x=1745026976; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=cSZkElQuxZTV1/D8NzqIO8txy29Fe8ChfyA1kCtXJjc=; b=expQ49LHOkuMzeynhwff9X397oAp+6/VTsZZDO/K0KfwmsDp9Pv43Qii o77Gv3d9d4CEey9Yus/TE0ypfzoRHDw+VRdfiMvTxeRSU4chiUhGrzntp WDOY8NOmX/B2JI9X1FjvG06deUvBJQH84/7cPofHAcQGq7IWC82guaK7j 89NXLhHP27+WZgB1uVmKsNXz67wWJIMOLUzis9eNz23JqKQ4P/HQSFHgL nHmcwJdpSHoghOy8wvFzlR+N3eBIW2NeNfUH3jFdwrrcllIMAsP+ucome f1sKVWN17B0dOydvRwS9RX6yRInVfAzSivHgZNcl+beAVsUXl0Fzmne+2 w==; X-CSE-ConnectionGUID: 7AEnpK7iScGwU1yme1Cg4g== X-CSE-MsgGUID: 87iGdm0DQeGtqRV9R4HCxg== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="9202175" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="9202175" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 18:42:55 -0700 X-CSE-ConnectionGUID: 1iL09b7CTDqgzgzUMFAIlw== X-CSE-MsgGUID: dw35IcYrRCet56oNwtTe1A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="23250130" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.124.242.47]) ([10.124.242.47]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 18:42:51 -0700 Message-ID: Date: Fri, 19 Apr 2024 09:42:48 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v19 110/130] KVM: TDX: Handle TDX PV MMIO hypercall To: Isaku Yamahata Cc: Sean Christopherson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, isaku.yamahata@linux.intel.com References: <20240418212214.GB3596705@ls.amr.corp.intel.com> From: Binbin Wu In-Reply-To: <20240418212214.GB3596705@ls.amr.corp.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 4/19/2024 5:22 AM, Isaku Yamahata wrote: > On Thu, Apr 18, 2024 at 07:04:11PM +0800, > Binbin Wu wrote: > >> >> On 4/18/2024 5:29 PM, Binbin Wu wrote: >>>> + >>>> +static int tdx_emulate_mmio(struct kvm_vcpu *vcpu) >>>> +{ >>>> +    struct kvm_memory_slot *slot; >>>> +    int size, write, r; >>>> +    unsigned long val; >>>> +    gpa_t gpa; >>>> + >>>> +    KVM_BUG_ON(vcpu->mmio_needed, vcpu->kvm); >>>> + >>>> +    size = tdvmcall_a0_read(vcpu); >>>> +    write = tdvmcall_a1_read(vcpu); >>>> +    gpa = tdvmcall_a2_read(vcpu); >>>> +    val = write ? tdvmcall_a3_read(vcpu) : 0; >>>> + >>>> +    if (size != 1 && size != 2 && size != 4 && size != 8) >>>> +        goto error; >>>> +    if (write != 0 && write != 1) >>>> +        goto error; >>>> + >>>> +    /* Strip the shared bit, allow MMIO with and without it set. */ >>> Based on the discussion >>> https://lore.kernel.org/all/ZcUO5sFEAIH68JIA@google.com/ >>> Do we still allow the MMIO without shared bit? > That's independent. The part is how to work around guest accesses the > MMIO region with private GPA. This part is, the guest issues > TDG.VP.VMCALL and KVM masks out the shared bit to make it friendly > to the user space VMM. It's similar. The tdvmcall from the guest for mmio can also be private GPA, which is not reasonable, right? According to the comment, kvm doens't care about if the TD guest issue the tdvmcall with private GPA or shared GPA.