Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp3479384rwp; Sat, 15 Jul 2023 03:43:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlHR2wwWeHxVkv8sFGDVXg+Otpn6rll9p6f7bQ8Oj9Ix4MObdVBp7utNhnmWlCXf50xD67xx X-Received: by 2002:a05:6a00:2342:b0:677:c5bf:dccc with SMTP id j2-20020a056a00234200b00677c5bfdcccmr7814277pfj.19.1689417825324; Sat, 15 Jul 2023 03:43:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689417825; cv=pass; d=google.com; s=arc-20160816; b=xXhwX5Wr9LbSQCzb74tT5QYJMQj3nbFW29n8iLJjKyGQvxsM7HWHBZN+cD8Q2J6vUJ 9kroZsWuFgr2tlnnvzxaQ+dZOLoDq15KsJUuP//q6ewxjqPPTQmq4KnU1HlOF6k0dUkl MP/4Fmu6OaZDHZxRUjvrTpVbPBghIHXvfZjYU7qqwk9AKIdnLO8H60Me8XSVo/BRTIeV kniwxgUw4WduAwvHM2fnaDstUyiaq2F7rrMesq7QPFjBMVHZWHFUj+JuJsHt7yxFMoRu yL/yE50vCmKID5iLqlQU0MGpk0SdfvPSPkNQgC2jiQagutlwkK6Loj7ZtW7ilqSgBapK RPaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:subject:from:references:cc:to:content-language :user-agent:date:message-id:dkim-signature; bh=bMQELH2IBpvPF+Gl+IwE63Rcm/inD1InxClaHByNRMM=; fh=ZQ6h4i6SsmVp5Ps/ZDgmTz45jj5bqX7FVUUchWanvs0=; b=pyI0Kqk4Aur0Vj0Q41uhFxd3stpVe0JH0nzVxzZQAggQ2FRAMHuwb0ZTsUj/uMkdW6 VsrU5GtwMxpj+tNbqS8cqhXKJMMKFSSp4f1KHmP/CSQncEeFkXOML/1EDNKc2ku64Z/h fAVQd4XC5EtvHs2VC624N5XTiudg/Ec/WwKCUCH0ByTeYtnx/aSx2tNVM0i2ztOqFrCe aihDV6JE61i9WpBUS7VWvU7VO4QEHVSXDX+rqrc/8Y7US23V8R7s6zL+g+cGOUnvRlwV ++0CwK7t8qk3zxHf7R+3rJwp17Zrb4U1RYu+Tjqkur/20rswjla4YjokuPc0uNLzI9Rs WTRg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=ADAaPy66; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a630d05000000b0053f23ffad1csi8519845pgl.544.2023.07.15.03.43.33; Sat, 15 Jul 2023 03:43:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=ADAaPy66; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbjGOKF6 (ORCPT + 99 others); Sat, 15 Jul 2023 06:05:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjGOKF5 (ORCPT ); Sat, 15 Jul 2023 06:05:57 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2059.outbound.protection.outlook.com [40.107.15.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E875535BB; Sat, 15 Jul 2023 03:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WBcD45oN5Xamx65FvTu8d1tY2hklDKtw4V6xHQ2ZpxHWhJvY6B4pxU4wo/mivVfDcTmpci5p5Td5wQ8l7BECFr0gmqntLL+KWHro6xPHFKekih3Fxe0TfbHYoTFvGHD1Vy+45ClbzNBFEp0bEcoe2QFrZ0mv6UGeI8IXbcC6+Lu58bxvRn2e274AKy91PSB40X6bxkNMitJifKrzZKM7tyLTYXVTythrCyS9vavKZM8MzdppsMx/8/I57A2jAe6qGLQFPYcxQaPl5HwVGAjZi5+0Gl9vPLARklhimaMhhNPML+RRmeI/RMwiR2/UWRWOQ+gCs6q7XMinibb77vGwpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bMQELH2IBpvPF+Gl+IwE63Rcm/inD1InxClaHByNRMM=; b=KlUuzXU6YliqdOlaSP/Ml36lQmNqw19Cts11oIlrGFvwlHbV5eMH7SeSanWouvXMxAN59YFtf2TBNcTN16iksLMz1ni05tzrPKso9pnV5cT8S6KeGOl3EQ82aY+nB1gDvp/Qhbqh4Ke6G2a1LocQnSPNiRQx8qY2zLiTTxhjRKeEwrc2avTBij19+40p6VoOpYtOzsxr7twGKaEPQM+NZWD9pzEMmSuPNTf7nb/AC4nMcWct05lY016+BwYX5GD52orteAQw8ax6aUAzrz/yJGKMIZlmC4bpYWRMYgZnXrFCf9t8s7BQOemW8MkXcf3ouzQVZ0RSliFVHMjCh9591A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bMQELH2IBpvPF+Gl+IwE63Rcm/inD1InxClaHByNRMM=; b=ADAaPy66KRbLlVpO6H8XNfi10Na+gAwn27RQpL1abvkOxWGoibFizJU2u94iMpEpIafFLQ3Kjhgd9tC0iypS9BjNvU/735OsC16h5+JOpXf/QYsW4ZtyhtjbxExFuo9MSZyDIzDxgUii3PN8POf27W6GLNngCe9rIy44AbjmGaXcZxbsQo+J9eXT5jk4XKb8O9uP7kgE6/fT9DUrYCPtyn41IkYUrYCfbs8aKfwPQpGkWS1jm/A2VCCrqwnT56rR/HZ2fWfhwqUvnF7rrJEqY2xhMrydclcJVr/JqTTux1olpD4rgohUz01frGQ5gprStcm+Y34AQznJ+dXPnbCkCA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from PA4PR04MB7790.eurprd04.prod.outlook.com (2603:10a6:102:cc::8) by DB9PR04MB9818.eurprd04.prod.outlook.com (2603:10a6:10:4ef::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.28; Sat, 15 Jul 2023 10:05:51 +0000 Received: from PA4PR04MB7790.eurprd04.prod.outlook.com ([fe80::66a2:8913:a22a:be8d]) by PA4PR04MB7790.eurprd04.prod.outlook.com ([fe80::66a2:8913:a22a:be8d%4]) with mapi id 15.20.6588.028; Sat, 15 Jul 2023 10:05:51 +0000 Message-ID: Date: Sat, 15 Jul 2023 13:05:48 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: Kai Huang , peterz@infradead.org, kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org Cc: dave.hansen@intel.com, tglx@linutronix.de, bp@alien8.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org, isaku.yamahata@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com References: From: Nikolay Borisov Subject: Re: [PATCH 08/10] x86/tdx: Unify TDX_HYPERCALL and TDX_MODULE_CALL assembly In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: VI1PR06CA0163.eurprd06.prod.outlook.com (2603:10a6:803:c8::20) To PA4PR04MB7790.eurprd04.prod.outlook.com (2603:10a6:102:cc::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB7790:EE_|DB9PR04MB9818:EE_ X-MS-Office365-Filtering-Correlation-Id: 36c675ef-6a21-4052-dc31-08db851b11db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UgJLUDwD4ecockFuAkvJgtfShDAMDqOgi+OCb1hu1if8ykvKxHmOM+jCkAxWAoq6+HA+OCigDT9Zo9LOmb5vFm15Ua6PUEEf2Dho71KB+vKpGo5lvhf9HCSkJPdj1dtkx3XpVVD59EINzNWFcAQSdhL95uhjZJ1s+KfpNHP9NL57fRi8GO4dMrU3L7FS3MLAJKkO3VkYwCsJQJZUqoNTvPN8l0rb9vLqEsp1qptyV0+a4wdreLrtaqtwYOYLbfYNn+k9ySurzoYg4hLWQ58sKcQTbuNK/PVbQgl9nZFBGHpBcHZxsPnQ7dYfam8cRN+HlwwIuw5sj3K4niUOmdbSr27iHzq8fWnhXrQrxf2sc/x9mKXZZVCG61OvnMehBpz+IIZrgN1oDyde3nR5no8fwFFW0UGQIFOzpkzqijWXX/jEPVDr6KKSXUkMdqUgM6dxp6D8YNnbgv7+u5yKOuiaQMCj0JLi2fMAXOmcffhrwLkZ18ku7UcDR/7wqNP/jWLBaLxcC4J4TgTSv+Ncr1INLvntuQsmBka5bIysSMNys50gNjGAEjO6iASffwTPGRJmiw/6TaPwXoxI9XSUqz4RX6epuYe8sQHUOLz6+H3LUiVTcaiK3IjUF97CnqiyHroinbFrGjrUc4HBE9tDWrN+9w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR04MB7790.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(366004)(136003)(376002)(396003)(39860400002)(346002)(451199021)(31686004)(66899021)(6506007)(38100700002)(478600001)(31696002)(7416002)(5660300002)(8676002)(4326008)(66946007)(66556008)(66476007)(8936002)(6512007)(316002)(86362001)(41300700001)(6486002)(6666004)(2616005)(186003)(36756003)(2906002)(83380400001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d09ZTFlGYjBKcWhkU3czVU1ZMFR3ck5wRDU3Q2RtTnR6eUVlOW92bDl2WFFx?= =?utf-8?B?R3RtVzZ0Ukl6SmlrbE9HWnVmdUQ2MkZPdmJuWTBkOWkvL3orREZ0b2xGek8y?= =?utf-8?B?ZWRDZVE0NEtxL2F4N3FNM0xpWXo3TUtsVUVXbzQ3UVBpMWJJdDlsVE5hZVF5?= =?utf-8?B?cmpoNXQ3bGlZTWlCbU5xN0sxTjBkYmtQZmppZ2tKcXNxZzltV0JWdllPVGJH?= =?utf-8?B?VTdiM2h3bG9JTndlSTkwb3h0Z09uSm1UdXNnSFNMVnJWRXVaZGJXM1dlS0J1?= =?utf-8?B?SnY5RHZJSWJGUmpQRGxLclJaaVozd1FMeFNaM0Q4ajlMaEVrSXgwdWltdkVl?= =?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clpmc3RUbllNZnRpQTNJbW5OQmpGaENnbjZa?= =?utf-8?Q?332D1nm7WklMxL2Yibuw6MMYbW9ye83Ey158EuvyO9h+?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36c675ef-6a21-4052-dc31-08db851b11db X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB7790.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2023 10:05:51.4691 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Hjx5Z+LBnf9hDtoG/0wbCHGBCqcJiOoae/zCkUpfpie5vYPwXTQxJjJLL/G1VqQ/0wPPy9GCgHW+u0b1SjbgEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9818 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c > index 0f16ba52ae62..a5e77893b2c0 100644 > --- a/arch/x86/coco/tdx/tdx.c > +++ b/arch/x86/coco/tdx/tdx.c > @@ -51,13 +51,38 @@ > > #define TDREPORT_SUBTYPE_0 0 > > +/* Called from __tdx_hypercall() for unrecoverable failure */ > +static noinstr void __tdx_hypercall_failed(void) > +{ > + instrumentation_begin(); > + panic("TDVMCALL failed. TDX module bug?"); > +} So what's the deal with this instrumentation here. The instruction is noinstr, so you want to make just the panic call itself instrumentable?, if so where's the instrumentation_end() cal;?No instrumentation_end() call. Actually is this complexity really worth it for the failure case? AFAICS there is a single call site for __tdx_hypercall_failed so why noot call panic() directly ? > + > +static inline u64 __tdx_hypercall(struct tdx_module_args *args) > +{ > + u64 ret; > + > + args->rcx = TDVMCALL_EXPOSE_REGS_MASK; > + ret = __tdcall_saved_ret(TDG_VP_VMCALL, args); > + > + /* > + * RAX!=0 indicates a failure of the TDVMCALL mechanism itself and that nit: Why mention the register explicitly, just say that if __tdcall_saved_ret returns non-zero .... > + * something has gone horribly wrong with the TDX module. > + */ > + if (ret) > + __tdx_hypercall_failed(); > + > + /* The return status of the hypercall itself is in R10. */ > + return args->r10; > +} > + > /* > - * Wrapper for standard use of __tdx_hypercall with no output aside from > - * return code. > + * Wrapper for standard use of __tdx_hypercall() w/o needing any output > + * register except the return code. > */ > static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15) > { > - struct tdx_hypercall_args args = { > + struct tdx_module_args args = { > .r10 = TDX_HYPERCALL_STANDARD, > .r11 = fn, > .r12 = r12,