Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2207934rwd; Fri, 9 Jun 2023 08:05:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5V9OLRXjcwjAEafzvAXNUpVt0th4GZNzQQ1+ODHLu/IokB/XYgHJoqB1udzmjibHsaNrH1 X-Received: by 2002:a17:902:e884:b0:1b2:61eb:a735 with SMTP id w4-20020a170902e88400b001b261eba735mr1171630plg.38.1686323115150; Fri, 09 Jun 2023 08:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686323115; cv=none; d=google.com; s=arc-20160816; b=wVSWZ73EVqe41s2UdfMd0MdKYoWfW/msHp2N+VyRIFSGuvgadHfV67vK4OL3azTQef KX75JZK9Pshn6n/V0soFiIoYlX5fUS01NjXqLfhmNgOhdcccpdaHCr/V0Xp3KlDdnD76 fz/UWVRdGZuh6Ty9YHX02AGHby+u5Ur+f2XPa0y9Pj6ewdsZfOASdKoUs5z2B8/P+Y8e pEQ69TFIfqtPovJEVtpZy/VZJt1AW27qw+GoRk2TcSHhyln9lujIr1WScFL2U3RHC54E p8AVNKFAulu+I9qOFK6Z2ZovfAuUVlQmFL+07axWH2fTbWf3HCSpbCho1cRmiTJQnQW9 Eyzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=zO8ENOnSimS6n7gy9/kTHBLX2Up3InmL5+w7nO9x+a4=; b=NO053PsxZBRFHsHz1WwtvinElw2s5yActSxHRojUlv0RlycEqsNqQMi9ShiaUPbMzi Bsn/lrYzKPRlJTo/t+D7eTC0uunvhgIaz7BrX8v5YPUH6pUf78weQhChvQ8PkoWzo6F6 AQg2XWYQDPPuGvVETGn3sGVjrK0gZ5k0p0+kjOCkiRsKfpI59f22ooRbZMhg9cnbmhgO FDnaCwkc5e7IpeQ/H8YeShKjGokfBHDvVTQmEqumvp7+ZdryzAaXTU2i/Lsvxq8KRA2u /poDZb7jwDsBA32itXyVBkGW1tBKyPIA3UqIAc/dqfcC2Ge2EA8xVjs2GkrHZxQ8ayW7 jKHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mFpiqwqW; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jb6-20020a170903258600b001b0113e1024si2736962plb.361.2023.06.09.08.05.00; Fri, 09 Jun 2023 08:05:15 -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=@gmail.com header.s=20221208 header.b=mFpiqwqW; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240881AbjFIOnC (ORCPT + 99 others); Fri, 9 Jun 2023 10:43:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230431AbjFIOnA (ORCPT ); Fri, 9 Jun 2023 10:43:00 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCC54E43; Fri, 9 Jun 2023 07:42:59 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f7378a75c0so13981575e9.3; Fri, 09 Jun 2023 07:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686321778; x=1688913778; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zO8ENOnSimS6n7gy9/kTHBLX2Up3InmL5+w7nO9x+a4=; b=mFpiqwqWl2vdGhX6AJu3w1NHIIZoQi6trxq0Lqp+ylDiBSnZiasMfSJxrk8StXj146 bsFIpsnfeKf/pNWC/J7X6wDvXx3YJx06hGc/aoUNjRZBE/hojOLO4TolDHwlNlaktdLB HgJSDRPKW625qqxAZHmsfjs0fqEDTf5DUQ51s+DY78dzKkpZzUuTrKbgfipgdJnAplvh 7yUqJSSwDnZ12P5iQD6U38lPC22hA1OGjLKncZsA/O9leoWMO2Znn9bIuG116hNxi/i/ i/D4QRmYjQ8FgsH9xDbo33qHBT4pcYmPKSkqW7tbbY8IkqOCwYxOFtLXo3VsmZ6XSx9b mR2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686321778; x=1688913778; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zO8ENOnSimS6n7gy9/kTHBLX2Up3InmL5+w7nO9x+a4=; b=jupv8FwBpt5W/GU03ZIaNx+FF0tAzZEazn0pm4azyhOrINXUMZzLz0IHv70XFMoZN+ 6AdQCIOv6JgVfhgFKfTMvpwFax03UqmN5a8FDi70FryeCPmOiEoY4v6pCWtboxWnO+TN k/OkURQa88BJA/XR9ALSlo8uJQNYjugUnmxzs7yfSl7Snhy2bCx+B8wcHKj1qSl9XjI0 yE8ycxdWpsHw12b477U/ESXNk8Bo1jZO3W6kKJdw0zXB8thMcDc3SWpgYD0VnWU4Ba16 RFLYhoND7Y1J8DokiQ4SYSkHbUTLJiYIknpn55TqhOZxmwmcsR5A46mr0LlhGNInihSO xrjA== X-Gm-Message-State: AC+VfDxo0wSvoo17fyoG8vwR/I5mhw6uw1xX/URO+eCr/Ct0ysi5YuI2 obpi1pS8+n1yqvs+eX6F6hk= X-Received: by 2002:adf:fd43:0:b0:309:3df3:8e0f with SMTP id h3-20020adffd43000000b003093df38e0fmr1093526wrs.51.1686321778019; Fri, 09 Jun 2023 07:42:58 -0700 (PDT) Received: from ?IPV6:2a10:bac0:b000:7727:c9f1:3163:7113:1dbf? ([2a10:bac0:b000:7727:c9f1:3163:7113:1dbf]) by smtp.gmail.com with ESMTPSA id x5-20020adff0c5000000b003078a3f3a24sm4637525wro.114.2023.06.09.07.42.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 07:42:57 -0700 (PDT) Message-ID: <51f4c068-7dbc-6f7d-fa49-b98807b74bee@gmail.com> Date: Fri, 9 Jun 2023 17:42:55 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v11 06/20] x86/virt/tdx: Handle SEAMCALL running out of entropy error Content-Language: en-US To: Kai Huang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: linux-mm@kvack.org, dave.hansen@intel.com, kirill.shutemov@linux.intel.com, tony.luck@intel.com, peterz@infradead.org, tglx@linutronix.de, seanjc@google.com, pbonzini@redhat.com, david@redhat.com, dan.j.williams@intel.com, rafael.j.wysocki@intel.com, ying.huang@intel.com, reinette.chatre@intel.com, len.brown@intel.com, ak@linux.intel.com, isaku.yamahata@intel.com, chao.gao@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, bagasdotme@gmail.com, sagis@google.com, imammedo@redhat.com References: <9b3582c9f3a81ae68b32d9997fcd20baecb63b9b.1685887183.git.kai.huang@intel.com> From: Nikolay Borisov In-Reply-To: <9b3582c9f3a81ae68b32d9997fcd20baecb63b9b.1685887183.git.kai.huang@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 4.06.23 г. 17:27 ч., Kai Huang wrote: > Certain SEAMCALL leaf functions may return error due to running out of > entropy, in which case the SEAMCALL should be retried as suggested by > the TDX spec. > > Handle this case in SEAMCALL common function. Mimic the existing > rdrand_long() to retry RDRAND_RETRY_LOOPS times. > > Signed-off-by: Kai Huang > --- > > v10 -> v11: > - New patch > > --- > arch/x86/virt/vmx/tdx/tdx.c | 15 ++++++++++++++- > arch/x86/virt/vmx/tdx/tdx.h | 17 +++++++++++++++++ > 2 files changed, 31 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h > index 48ad1a1ba737..55dbb1b8c971 100644 > --- a/arch/x86/virt/vmx/tdx/tdx.h > +++ b/arch/x86/virt/vmx/tdx/tdx.h > @@ -4,6 +4,23 @@ > > #include > > +/* > + * This file contains both macros and data structures defined by the TDX > + * architecture and Linux defined software data structures and functions. > + * The two should not be mixed together for better readability. The > + * architectural definitions come first. > + */ > + > +/* > + * TDX SEAMCALL error codes > + */ > +#define TDX_RND_NO_ENTROPY 0x8000020300000000ULL Where is this return value documented, in TDX module 1.0 spec there are only: 8000020[123]00000000 specified and there's 80000800 (TDX_KEY_GENERATION_FAILED) and its description mentions the possible failure due to lack of entropy?