Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3104079pxj; Mon, 14 Jun 2021 14:39:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQk8yAttIrRo2JvLDCQgqnPOQgLSbwT9ttbR7Fd5ngC/BiNNhG9MkCWle34f0mRHPZ0bZR X-Received: by 2002:aa7:cd06:: with SMTP id b6mr19130657edw.191.1623706743551; Mon, 14 Jun 2021 14:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623706743; cv=none; d=google.com; s=arc-20160816; b=RAPKoUxAFmUMC2u2BtHmWST9CXEQUJjF9wFjRXMxEhA/fNvFhN/lfynNFr1eO6hJw1 28W5lCxW4ziYTTejCn71pa0FVzPSm2Akbmj9axA0a4fFOGy0WT0ekBV0/+LtUXp8ioQR lGYqs4maNUavtwVMdIB0/Spf/myMqx3doJYCw4cilRaOInBHqnOmm3OcWjxOmi0eMbcW Vr/ArC6ga4a7jv+aAvtopzp9E98tfyqcZew9ey31+2Bp30gGi6OFk8EKbp0E5GjGtpwk JHdAwr1egpUByoxmXciaGUmdWwZg+ibfriTJYFfTausBClmwNznYPVSaFfwRPF3WRCWr fQ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=GzIiZgbvwE2HIxiUUDGPVWwxufQCFB4j/CYVlnaHq0w=; b=N0bqC/LzosLS1BCB1843e/4Trbg7c7SiqlG7YNOjrTDx/36oacpSefIon4U4XwwVrw VLVISvzQXiVwX7Bbj7BI+bDbe3a6IYnKhoquo+oi1B7uTSoUrGbCxwNtL47nOdI9cv8J 3uKW5Zv6e30Js/rigNnBoLjBSyElX4vUhn4sKWbM6UWlxnHy+2+P68xz3L6o2tGTQ9er Uk5he/cZJAgl3UxhZRRclyoX9qMMGeWZqpql/6NN+1P4FaXkf6gWcn/lOS+dMl+xh1XE gyr2m5fBx3vW78DX6OBF1qS8jmfogJniQ3OPTDds51BvPbk+7HfaXjY88kSbgHhl8p8h eR6Q== 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 d14si12487179edp.279.2021.06.14.14.38.41; Mon, 14 Jun 2021 14:39:03 -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 S232631AbhFNVjn (ORCPT + 99 others); Mon, 14 Jun 2021 17:39:43 -0400 Received: from mga03.intel.com ([134.134.136.65]:27355 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232594AbhFNVjm (ORCPT ); Mon, 14 Jun 2021 17:39:42 -0400 IronPort-SDR: xNAy/e81YPOv5q2pRvUeDxLnViQFJMJSdqoI6AeBxMOL85C8THaQFnsmhaLN8+Pk/0MKFmiRHc pTt6/gI/yx2g== X-IronPort-AV: E=McAfee;i="6200,9189,10015"; a="205915643" X-IronPort-AV: E=Sophos;i="5.83,273,1616482800"; d="scan'208";a="205915643" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2021 14:37:36 -0700 IronPort-SDR: I7Mm/rg0UCZZSwPpyzexFGL4qtaF+Ik80rtJg56L1lyH6oB6n5oaE4My+rXSyFLwbyQoddeNAk vfOPvuVvRedQ== X-IronPort-AV: E=Sophos;i="5.83,273,1616482800"; d="scan'208";a="621154130" Received: from unknown (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.209.156.97]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2021 14:37:35 -0700 Subject: Re: [PATCH v1 05/11] x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions To: Borislav Petkov Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Sean Christopherson , linux-kernel@vger.kernel.org, x86@kernel.org References: <20210602022136.2186759-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210602022136.2186759-6-sathyanarayanan.kuppuswamy@linux.intel.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: Date: Mon, 14 Jun 2021 14:37:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/14/21 1:11 PM, Borislav Petkov wrote: > On Mon, Jun 14, 2021 at 12:45:45PM -0700, Kuppuswamy, Sathyanarayanan wrote: >> May be I should define a macro for it and use Mov to keep it uniform >> with other register updates. > > Macro? > > There's the, well, *MOV* instruction, if you insist on keeping it > uniform. But this is not about keeping it uniform - it is about having > the code as clear as understandable as possible: > > > /* Set RAX to TDCALL leaf function 0 */ > xor %eax, %eax > > Plain and simple and clear why the XORing is done. Ok. I will fix the comment. >> With the trace support, they should be able to see the flow before making >> the tdx_*_call(). That should be enough clue for debug right? > > Are you expecting all those cloud users to trace their guests just to > figure that out? I'm sceptical they will... > > Rather, I'd try to allocate a special error value that > do_tdx_hypercall() returns in %eax and then have the wrapper which will > puts %r10 on the stack, check that error value and panic with a nice > error message. > I will add r10 to struct tdx_hypercall_output and return it to callers to check it. > > Btw, where is that function used? Gurgling, it shows it in some MMIO > patch, I'm guessing that's still coming. > > As to how to do it properly, you pass in > > struct tdx_hypercall_output *out > > as a function parameter and caller can pick out whatever it wants from > that struct. It looks like it is used only in MMIO use case now. I think we don't need it anymore. I will remove it. > > Thx. > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer