Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2623511pxb; Sun, 17 Oct 2021 20:48:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPLcw5zE3lRa9ffl5fr3/DVKUmgtgNEwHPEblv1hIEDLhJI9EWMR94Bmd9BbkQzzyklQvF X-Received: by 2002:a17:90b:1bcc:: with SMTP id oa12mr30203677pjb.212.1634528925175; Sun, 17 Oct 2021 20:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634528925; cv=none; d=google.com; s=arc-20160816; b=xOM7XWk+OiOpmffHJY3nBSfsy28g98plNVaJaKHO1W2iq1zJbFrMI834BiXkepQ0mT KzFmjb64EvSK4ewFwB1NdqpRlEObQVHWOQYsAr9l4HjV5jb9SLoyvDowN+HWgoBdHAuz YsIpzzLHYqx79o9nstr0vBtDiGoq2WB3L3yYf+ZJXbJzj5CzUwhbHrUzKl9IA/tph7EQ VSuKf0Q4EbOE9niiR07X+nha6Ze6YlbJuI4/U+yTOcHnYLPR+RZJrACXUaLRJ587EUfA kJgMLVzVqLRrH42VcMYzc5fCIJFkDThQwo+Ps1Thp7yoZWGKUj14vl6yiSWuNCRPlAfJ Enxw== 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; bh=VmgaicNAK0Wko2DtGWLU7Vd7d80VJimrrNVo5vQg2fA=; b=wZgYkJuI1zG/d/Lh6BCrLi7xGxxds279tTsSK+e8A/ENx+fEOsSTGqDyh2gDOtwKi5 e85zdv1R9Zl88H2DcVz7IVPpf4ZGERS0SRNpzZhXqn1xoa4H/yPy4kGkBgiPEL+BiLHX wWc2SDLZTmAFyoUndfS/e/sO0kHgv4cN/LwiXPt0rHOtAZDrw+tU+T7PtQd2KFAGbrR4 P5rtQBjvcpN69xw4QaH9XbOLF+aoUaAtJwfPGGyXKaC0Oid/yh3gFA/4xC5RBa1/J1az XsfjcZrKIVT/uZ8wlz64rCeMvCI2D+itHOqITd2IwK32pbOSR4sWq8OcAdhG+BV05bCJ NbQA== 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 o32si19642275pgb.608.2021.10.17.20.48.33; Sun, 17 Oct 2021 20:48:45 -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 S242920AbhJQUhj (ORCPT + 98 others); Sun, 17 Oct 2021 16:37:39 -0400 Received: from mga18.intel.com ([134.134.136.126]:11991 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242454AbhJQUhf (ORCPT ); Sun, 17 Oct 2021 16:37:35 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10140"; a="215068719" X-IronPort-AV: E=Sophos;i="5.85,380,1624345200"; d="scan'208";a="215068719" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2021 13:35:25 -0700 X-IronPort-AV: E=Sophos;i="5.85,380,1624345200"; d="scan'208";a="565425995" Received: from ericalo-mobl.gar.corp.intel.com (HELO skuppusw-desk1.amr.corp.intel.com) ([10.254.45.96]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2021 13:35:24 -0700 Subject: Re: [PATCH v7 05/10] x86/tdx: Handle port I/O To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Paolo Bonzini , David Hildenbrand , Andrea Arcangeli , Josh Poimboeuf , "H . Peter Anvin" , thomas.lendacky@amd.com Cc: Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , linux-kernel@vger.kernel.org References: <20211005204136.1812078-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20211005204136.1812078-6-sathyanarayanan.kuppuswamy@linux.intel.com> <87v91v2zkk.ffs@tglx> From: Sathyanarayanan Kuppuswamy Message-ID: Date: Sun, 17 Oct 2021 13:35:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <87v91v2zkk.ffs@tglx> 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 10/17/21 12:58 PM, Thomas Gleixner wrote: > On Tue, Oct 05 2021 at 13:41, Kuppuswamy Sathyanarayanan wrote: >> \ >> static inline void outs##bwl(int port, const void *addr, unsigned long count) \ >> { \ >> - if (sev_key_active()) { \ >> + if (sev_key_active() || \ >> + cc_platform_has(CC_ATTR_GUEST_UNROLL_STRING_IO)) { \ > Instead of adding an extra check, can you please replace that > sev_key_active() with cc_platform_has() completely? Yes. sev_key_active() can be removed and replaced with cc_platform_has(). Thomas Lendacky also proposed to introduce as common static key which can be set by both AMD SEV and TDX code. @Thomas Lendacky, any comments? > >> +/* >> + * tdx_handle_early_io() cannot be re-used in #VE handler for handling >> + * I/O because the way of handling string I/O is different between >> + * normal and early I/O case. Also, once trace support is enabled, >> + * tdx_handle_io() will be extended to use trace calls which is also >> + * not valid for early I/O cases. >> + */ >> +static void tdx_handle_io(struct pt_regs *regs, u32 exit_qual) >> +{ >> + struct tdx_hypercall_output outh; >> + int out, size, port, ret; >> + bool string; >> + u64 mask; >> + >> + string = VE_IS_IO_STRING(exit_qual); >> + >> + /* I/O strings ops are unrolled at build time. */ > Fancy. The compiler can evaluate sev_key_active() and > cc_platform_has() at build time? It is incorrect. I will fix this in next version. How about following change? I/O strings are replaced with in/out instructions. If string is reported, report it with BUG. > > Thanks, > > tglx -- Sathyanarayanan Kuppuswamy Linux Kernel Developer