Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1847204rwl; Wed, 12 Apr 2023 20:31:20 -0700 (PDT) X-Google-Smtp-Source: AKy350buFGI43nisoWsTrWgDNMfaZt3D4whvrcVGEwIB8hOVRygpYvolzqg2LZJ+1+7IsuFjlHMa X-Received: by 2002:a17:902:daca:b0:1a6:87f7:2dbf with SMTP id q10-20020a170902daca00b001a687f72dbfmr472866plx.62.1681356680564; Wed, 12 Apr 2023 20:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681356680; cv=none; d=google.com; s=arc-20160816; b=V4SZD0rBsr4IBMhDaWTIa04wBCbKdu93py+eoJgxLUoZ3tjODCOn/sx+yxYgCVDED4 ekBNFs0Zm8Isr0VC02Xwr0Nl/c6ixgEc7wEvVuDq+z/FAI+7HgP38B0y+PxUilG+fsg0 hvhgFWZKGGCHj6B/vA7WWSBO3A4HyIUT8NPcK7vuXgZPzCDeBAoGCOhMJAH7XGVJavva mfEzDMwhghjqk+CTqYAuPWQuTnZ+Y7HRzkFSNfBPLDy7VxsjB8Uj0deGEs45LBFVYNIj oWDJ+TcwadxtGVLrwJ59BDeJKER4fZ2mO2vw8L6PltKIpwp3DP5RveRvJXGkXzdWYAy0 W4ew== 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:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=9ct5vuDCIzGTNk2BukrX+dS6D2BQBnqAt9BW7ZooNL4=; b=nC9RomKP4MRexDKqI3lMfaCkjmg1UH2usukqc9oUtFxzyXnhrO+G1CxWMhoLlnIx1L 9NFR4IRR52bynkqe6u0Wm1X5yvoRs4ff+TXroxn6J5B0HtR7hZD79CX58h3UwZ2iEIaz 4HlU2Pc5WyPbckuRg1PoItbeobSY8kx0GsuaIShIXN60B5lMaZY5Abb7+ipgMuNgHxWY TJhPbknP9nvinq+jPjuZ8J7gWOgVtvceYIdajL5qszJLIjTIAunO5toi+GWHvFgOgu0R 8dbw/Os/q4whhPsjmW8COHXBujHRvBxi4l/3O8K3GOOayAM2kTnc87Er22oIxPBVE+jg +k5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=i51NDCHe; 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 m22-20020a170902bb9600b0019ca3bea310si800573pls.303.2023.04.12.20.31.09; Wed, 12 Apr 2023 20:31:20 -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=i51NDCHe; 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 S229674AbjDMD3w (ORCPT + 99 others); Wed, 12 Apr 2023 23:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjDMD3u (ORCPT ); Wed, 12 Apr 2023 23:29:50 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39B12139; Wed, 12 Apr 2023 20:29:49 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1a52674f1abso9563125ad.2; Wed, 12 Apr 2023 20:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681356588; x=1683948588; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=9ct5vuDCIzGTNk2BukrX+dS6D2BQBnqAt9BW7ZooNL4=; b=i51NDCHer5Nw5tsR6vq2qb3VFxbbEMt8N3XKCTXJn4CRPmo9u1H9DVKr6bUFmKd2qr UH6hyyjuajYvY+Ww1ecJgQ6TuYj6o8OL5qV+Kx/mTsHQZhTjA99KJveR27Tupro20RdJ AlxAWwLXCTNawsNaoZAs7/nh+vomwU7TGDy8TQCTnGQ3SfZTmPFBdw78aW0Kerczi3Rz VTQiPb29KOUwdX7tfrZsi9pkQtvJSV3p9+R7jZB3pX6u5LA5gbFtBAp6FtiU7Sgyq5Bn EuQEgt258NXfxoTPwWx+lA9ac4RP70bNejZdgTytiP+IzGz/GoApaUEZnhBKOvmOjjtV wmYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681356588; x=1683948588; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=9ct5vuDCIzGTNk2BukrX+dS6D2BQBnqAt9BW7ZooNL4=; b=LSg2kIDL6pOqSV2HuAYFFI/tqVCvtwc+TJlf3IpgTnnNPRpjcBWSxZ/JHumdXtA4wN Qu9GvlNqqgPX6nb3ouO/Z1D+U9mtuxQnse/jKy07K0MgmoPSqQQpdJXfZZFdbHDPLMdY ap2o/hG+n/D7CY85SukMk/Tw6LrPo71gXQeOwso/WIvj6aLNbfzV3S16sNF8KOsIA1bF AHL9siBUgMFYYA/02i7JvLCbQaO/v5OXdvC9jlK2in1rwW9lNv+QaPKDKbJkMgulQsd2 McQzYhrs2LFhLpmYiWz9vLJjC4tKIBV2aprbTlZZGX0mSyGddvWKxpPgW6/+BpIpkBal Pq2Q== X-Gm-Message-State: AAQBX9eEOg4AUKyCRixTpW92Jj39vlz2xPKj16tuBfPHlZCecZ0BnIUs r2lWe9hx/aGL4Irgw0tlBgQ= X-Received: by 2002:a05:6a00:a1d:b0:637:f1ae:d47 with SMTP id p29-20020a056a000a1d00b00637f1ae0d47mr1369781pfh.17.1681356588596; Wed, 12 Apr 2023 20:29:48 -0700 (PDT) Received: from ?IPV6:2404:f801:0:5:8000::75b? ([2404:f801:9000:18:efec::75b]) by smtp.gmail.com with ESMTPSA id s5-20020aa78d45000000b005941ff79428sm199275pfe.90.2023.04.12.20.29.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Apr 2023 20:29:48 -0700 (PDT) Message-ID: <518e2a05-a4e8-8dbb-8ba0-8e8cf80a57d2@gmail.com> Date: Thu, 13 Apr 2023 11:29:36 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [RFC PATCH V4 03/17] x86/hyperv: Set Virtual Trust Level in VMBus init message To: "Michael Kelley (LINUX)" , "luto@kernel.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "hpa@zytor.com" , "seanjc@google.com" , "pbonzini@redhat.com" , "jgross@suse.com" , Tianyu Lan , "kirill@shutemov.name" , "jiangshan.ljs@antgroup.com" , "peterz@infradead.org" , "ashish.kalra@amd.com" , "srutherford@google.com" , "akpm@linux-foundation.org" , "anshuman.khandual@arm.com" , "pawan.kumar.gupta@linux.intel.com" , "adrian.hunter@intel.com" , "daniel.sneddon@linux.intel.com" , "alexander.shishkin@linux.intel.com" , "sandipan.das@amd.com" , "ray.huang@amd.com" , "brijesh.singh@amd.com" , "michael.roth@amd.com" , "thomas.lendacky@amd.com" , "venu.busireddy@oracle.com" , "sterritt@google.com" , "tony.luck@intel.com" , "samitolvanen@google.com" , "fenghua.yu@intel.com" Cc: "pangupta@amd.com" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "linux-arch@vger.kernel.org" References: <20230403174406.4180472-1-ltykernel@gmail.com> <20230403174406.4180472-4-ltykernel@gmail.com> From: Tianyu Lan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.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 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/12/2023 10:24 PM, Michael Kelley (LINUX) wrote: >> +static u8 __init get_vtl(void) >> +{ >> + u64 control = HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_REGISTERS; >> + struct hv_get_vp_registers_input *input; >> + struct hv_get_vp_registers_output *output; >> + u64 vtl = 0; >> + u64 ret; >> + unsigned long flags; >> + >> + local_irq_save(flags); >> + input = *(struct hv_get_vp_registers_input **)this_cpu_ptr(hyperv_pcpu_input_arg); > The cast to struct hv_get_vp_registers_input isn't needed here. Just do: > > input = *this_cpu_ptr(hyperv_pcpu_input_arg); > > I know we have other code that references hyperv_pcpu_input_arg with a more > complicated code sequence, but it's really not necessary. At some point, we > should go back and clean those up, but let's not add any new cases. ???? Hi Michael: Thanks for your review. Yes, agree. I just follow the old coding style and will update. > > >> + output = (struct hv_get_vp_registers_output *)input; >> + if (!input) { >> + local_irq_restore(flags); >> + goto done; >> + } >> + >> + memset(input, 0, sizeof(*input) + sizeof(input->element[0])); > Use struct_size() to calculate the size of a structure plus a trailing > variable size array. > >> + input->header.partitionid = HV_PARTITION_ID_SELF; >> + input->header.vpindex = HV_VP_INDEX_SELF; >> + input->header.inputvtl = 0; >> + input->element[0].name0 = HV_X64_REGISTER_VSM_VP_STATUS; >> + >> + ret = hv_do_hypercall(control, input, output); >> + if (hv_result_success(ret)) >> + vtl = output->as64.low & HV_X64_VTL_MASK; >> + else >> + pr_err("Hyper-V: failed to get VTL!"); > Let's include the hypercall status in the failure message. If a failure ever > happens, we will really want to know what that status is. ???? > Agree. Will update. >> rv; >> extern bool hv_nested; >> @@ -58,6 +59,7 @@ extern void * __percpu *hyperv_pcpu_output_arg; >> extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr); >> extern u64 hv_do_fast_hypercall8(u16 control, u64 input8); >> extern bool hv_isolation_type_snp(void); >> +extern bool hv_isolation_type_en_snp(void); >