Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp719104rdb; Tue, 19 Sep 2023 08:15:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZbctONmW3TfYXyP55mLVIQRN+SlTwIG4Ciamqt2ly5MhMT9ggk+BrTTHoyIVTUmQb/e/t X-Received: by 2002:a17:90b:1e02:b0:269:18f5:683e with SMTP id pg2-20020a17090b1e0200b0026918f5683emr7563pjb.3.1695136525001; Tue, 19 Sep 2023 08:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695136524; cv=none; d=google.com; s=arc-20160816; b=yXammh6A/5MVN9tFkP1GCGTqagShzXo023/XbbYuRile4Zi0eEzeP3AhNnKlMZSZG7 F68+7v0hKK0p63uoLzHksa30UUr4OvPDJW3zW47Zks3ow0b9FFZ0ORKwVMGkkx6LPUKZ +Wsm0c5crgSdgd45j/j9TqVzAzN/wzhWD1/wPUUd51jOKS9VCHbeuiw0UK3jIhmeJnmN wS2UqHhDPv1XZVqNQTvwLYz+A++JgycpHkJqMgES6XvjJAkabfIJgH3xO6muGGKkCRMH gTLLGkfjlXbkqxh+rpZSS5dvBCyyr86r1RC7FhI6G8S3p8tKeiJ3zjVuii/0ifiIxvOq /pCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=wpbrdLK1aN164ZiqLi72UGFResb0onUWuvtwINnIXW4=; fh=XbEli3iO/n489AK7w3rvsJcb6aQXOUHapazu5O12ngc=; b=BYM21ztVsbVQUWApwwAyV76vGnfIssNjSi6p7tdWw5I4JSVsh/XG2hZvAIdoFpy6aT SgUHox8pvjsaDLXxMthmlQl/WV+0qdKRW1Myihwbg/EWSItku4ekZMb65znnDc8ys9br w+0OWaBRPiOppdGk2RaxqgrwWk4p4GlruNrohNlbY1yWzqkYK0NsD9GqkYGAkxczg5C3 /yw4Jm23R3ZeWHBT5j+9gPJR/q4L/NrNUfhtFjOIGhgHs1+I4SMhEKoGs4q+w13YacYu +ByElbsMMl85w199B1vH3oI6ihzLd2TC4ijvTyeXV4jEf+YyDAqp8AfSWBv8rdGm42rX HmVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KNTkx4Wu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id nv7-20020a17090b1b4700b0026b31ed4895si12907805pjb.29.2023.09.19.08.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 08:15:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KNTkx4Wu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7649180879C2; Tue, 19 Sep 2023 04:05:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbjISLFs (ORCPT + 99 others); Tue, 19 Sep 2023 07:05:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231937AbjISLFg (ORCPT ); Tue, 19 Sep 2023 07:05:36 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CA30F7 for ; Tue, 19 Sep 2023 04:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695121489; 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: in-reply-to:in-reply-to:references:references; bh=wpbrdLK1aN164ZiqLi72UGFResb0onUWuvtwINnIXW4=; b=KNTkx4WuAQMIrdcdYO1Flgxg+u/oQF3OK6F1oPnO2Os7O2WDrWfSi76lClNxUiUK24dUVb AW0xfazdn9lX1ZtWwYFNyhssVgbp66NsGWmcVWoQObUss9RhKca62rWCJXb3JbFIIo6F7l NSlvvU8JUy75+uSGiD5fjyiP/gludQw= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-159-RPgXSEg0MPeuQF79W_cuoQ-1; Tue, 19 Sep 2023 07:04:48 -0400 X-MC-Unique: RPgXSEg0MPeuQF79W_cuoQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-99388334de6so402143766b.0 for ; Tue, 19 Sep 2023 04:04:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695121487; x=1695726287; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wpbrdLK1aN164ZiqLi72UGFResb0onUWuvtwINnIXW4=; b=Jz0pLeNMXlcjtvQ7WYNfO4D5EKri4CiDK/80a3BnlL6QpzvBZDMMoSDG6yP8WinuOY ew1qAZtPzzDdlJu7whykpe5b1qj7hGspFpI0YncM5m3dfYoNjnjw7ktncWgsVfeSeo46 kgGs+mT72KTcz4oOrTtl77Pcy/BixAp17VvZFIdPWSg01IKh23JorFC+j+Zd3vPPvTIU GoSqrLIVkb01sbjtfe7KjctTGx45/lZSrN7kn+ojzYfDXV3A4a1Bf0gFcJCmNBdS+gk+ E6lLWSmTXLGAZDz1pk0I5G6kfKGyUrBwvg1Y4+c9GdrM7ecf672A5+Ni+JNXqLoKbqkN fvrQ== X-Gm-Message-State: AOJu0Yy4XakDyte4iLaIQQpPWyoRkzPb2vbIY+JqSt+w+RYPAJS7YBlV CeSlRLMyiUYc/EbYSPqomAtrngv+XI5hmnG4GCKde1sO8Wxeq1IsGjQ75tXD8vEZmmwZP0lFA7H VWm1dDQJ/cLQUri0EbuqIoOOGpfsU07IJlRY= X-Received: by 2002:a17:907:6087:b0:9a5:cf6f:3efc with SMTP id ht7-20020a170907608700b009a5cf6f3efcmr8673796ejc.77.1695121487492; Tue, 19 Sep 2023 04:04:47 -0700 (PDT) X-Received: by 2002:a17:907:6087:b0:9a5:cf6f:3efc with SMTP id ht7-20020a170907608700b009a5cf6f3efcmr8673775ejc.77.1695121487204; Tue, 19 Sep 2023 04:04:47 -0700 (PDT) Received: from fedora (g2.ign.cz. [91.219.240.8]) by smtp.gmail.com with ESMTPSA id ck19-20020a170906c45300b0099297c99314sm7594521ejb.113.2023.09.19.04.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 04:04:46 -0700 (PDT) From: Vitaly Kuznetsov To: Saurabh Sengar Cc: ssengar@microsoft.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com Subject: Re: [PATCH v2] x86/hyperv: Restrict get_vtl to only VTL platforms In-Reply-To: <1695101408-22432-1-git-send-email-ssengar@linux.microsoft.com> References: <1695101408-22432-1-git-send-email-ssengar@linux.microsoft.com> Date: Tue, 19 Sep 2023 13:04:45 +0200 Message-ID: <87jzsme84y.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 19 Sep 2023 04:05:49 -0700 (PDT) Saurabh Sengar writes: > For non VTL platforms vtl is always 0, and there is no need of > get_vtl function. For VTL platforms get_vtl should always succeed > and should return the correct VTL. Nitpicking, an alternative summary: """ When Linux runs in a non-default VTL (CONFIG_HYPERV_VTL_MODE=y), get_vtl() must never fail as the result it returns is used in negotiations with the host. In the more generic case, (CONFIG_HYPERV_VTL_MODE=n) the VTL is always zero so there's no need to do the hypercall. Make get_vtl() BUG() in case of failure and put the implementation under "if IS_ENABLED(CONFIG_HYPERV_VTL_MODE)" to avoid the call altogether in the most generic use case. """ > > Signed-off-by: Saurabh Sengar Reviewed-by: Vitaly Kuznetsov > --- > [V2] > - Put the if else at function definition rather then at the caller > > arch/x86/hyperv/hv_init.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > index 783ed339f341..f0128fd4031d 100644 > --- a/arch/x86/hyperv/hv_init.c > +++ b/arch/x86/hyperv/hv_init.c > @@ -394,6 +394,7 @@ static void __init hv_get_partition_id(void) > local_irq_restore(flags); > } > > +#if IS_ENABLED(CONFIG_HYPERV_VTL_MODE) > static u8 __init get_vtl(void) > { > u64 control = HV_HYPERCALL_REP_COMP_1 | HVCALL_GET_VP_REGISTERS; > @@ -416,13 +417,16 @@ static u8 __init get_vtl(void) > if (hv_result_success(ret)) { > ret = output->as64.low & HV_X64_VTL_MASK; > } else { > - pr_err("Failed to get VTL(%lld) and set VTL to zero by default.\n", ret); > - ret = 0; > + pr_err("Failed to get VTL(error: %lld) exiting...\n", ret); > + BUG(); > } > > local_irq_restore(flags); > return ret; > } > +#else > +static inline u8 get_vtl(void) { return 0; } > +#endif > > /* > * This function is to be invoked early in the boot sequence after the > @@ -604,8 +608,7 @@ void __init hyperv_init(void) > hv_query_ext_cap(0); > > /* Find the VTL */ > - if (!ms_hyperv.paravisor_present && hv_isolation_type_snp()) > - ms_hyperv.vtl = get_vtl(); > + ms_hyperv.vtl = get_vtl(); > > return; -- Vitaly