Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3053070pxj; Mon, 14 Jun 2021 13:15:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRR8tyep8fqp01JKW5e0au9hNTqGnAXd1vzfuHM7mlb/lX2aXOzg5HAHoZ8Xs0XjAAbMCh X-Received: by 2002:aa7:d388:: with SMTP id x8mr18593660edq.338.1623701755500; Mon, 14 Jun 2021 13:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623701755; cv=none; d=google.com; s=arc-20160816; b=G3Sg+6xoOSOj4WoPTwnvsLA05HrybyN37HvbTahTM2bxSo9VMYHY3VFWJibDfii/Dq fYgHFykmFPNNXvbvm/dOeKl9YRtcV6uVb+90AzFOA7yJsmLRrGTlLYA2YEM9+V31rFmw YuoWwKJQa+U5afDOgy1Z27D2WemjvKlW6Rxw4MJBKSxZ8xM31ZWqKXj785CgURlKKS7Y MgNXD+LBut9U2RyvZJd9TQ2t/0vLbSXzPBKlTUTLMsX/Jze2H2GMuot3ExIJQpgU9K9d dKI0kvBbn3gk/ZexeagF4Ci7B1L5rr93GQipPKRP4+CNCbBDkwkHWn5I+cl8FTZ2rbRX fwgg== 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=YLEhCAu033Ko8s2B8FzpAXaxJKlECW6GNIUYVXNIkQE=; b=wYZd85kbqgPj+8q/PCiYz74A0+lU/4GCk9t7egpVl19twJLlSgQF1l78qmMh0JN69e 53Va4ymSKht+U0sSPwj8ajHRKacqfTGACo7hfmCvBZ9tQJfMFcMf7ed7JKm1234rpHIA K1iIMtdUYEKHlqnT0jkvJtwTtU+CULEN++vk5jvxm3UzZrZiAvuJvXzhQ8ymOiyiDr+w Y2xbNIPbqoRWoEOs+Q8A9HfGXLHHxFj8f3NfL06p0ysoUr0B0h07bARmhY4Ee4LkDriQ O8Ox83x6hMSSIA8MeINucJa1YyJSiPqDLjSkEdyGND4ftEnyTFZraYVuCFyk66Am4Yf3 iYoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ilceE67y; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j6si12406881ejo.589.2021.06.14.13.15.30; Mon, 14 Jun 2021 13:15:55 -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=@alien8.de header.s=dkim header.b=ilceE67y; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234656AbhFNUNi (ORCPT + 99 others); Mon, 14 Jun 2021 16:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235770AbhFNUN0 (ORCPT ); Mon, 14 Jun 2021 16:13:26 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7844BC061767 for ; Mon, 14 Jun 2021 13:11:23 -0700 (PDT) Received: from zn.tnic (p200300ec2f09b9000c5f6a5325ce378c.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:b900:c5f:6a53:25ce:378c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 91EE11EC04DB; Mon, 14 Jun 2021 22:11:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1623701481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=YLEhCAu033Ko8s2B8FzpAXaxJKlECW6GNIUYVXNIkQE=; b=ilceE67y8YnWP+BUuC6TjumeZ636ybrSUu7mJdcsizepjehdRIdcqHmMxehsNTPjOR+FhE Ge21GlebDKXLSMToJp3f/hWBf+ieBkyMCwZuo8+mJ9udZN8Sz/Bg00B94Z6DnvU2syKWzs z++mawFYn6Syxf5HZbnQ4MIRiA/iKiw= Date: Mon, 14 Jun 2021 22:11:14 +0200 From: Borislav Petkov To: "Kuppuswamy, Sathyanarayanan" 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 Subject: Re: [PATCH v1 05/11] x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions Message-ID: References: <20210602022136.2186759-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210602022136.2186759-6-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > But, I am fine with passing it via stack, if this is recommended. > > Please let me know. Yes, please do. > 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. > Ok. I will follow your recommendation. I have done it this way to fix > checkpatch reports. Yeah but you should not take checkpatch reports to the letter and use common sense instead. > If we need helper functions for other output registers in future, we might > have to add the suffix. 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. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette