Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8592375rwb; Thu, 24 Nov 2022 01:28:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf53vuq/i2FtAy+Y1LD1jkOzwyGSeZbUevPrcHRcRY1scchTv7kHjCKMVY3a2E/dUh4/65L2 X-Received: by 2002:a17:902:e415:b0:179:f94a:6fda with SMTP id m21-20020a170902e41500b00179f94a6fdamr26177568ple.118.1669282101380; Thu, 24 Nov 2022 01:28:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669282101; cv=none; d=google.com; s=arc-20160816; b=otw2Po+l7rPHsUoRSmcUNbnTNhWzKIRaU7v4/Q7A+ewVU5HgJCraL0NaEZz1CC3dif XECZrSIzOt5cVXvtZudYxiotgDBVx1FxGt+iepqpvthOIyAMhUfX+50VTBmA992ii349 +E3EU9s9lymj/cHuVfn+b3gprBwT5s6UB/steB+pioZPnNu0HZlIbSGUM6Nlp8CqRqZk +Tgm2j1F+/0/tQLSVXNNWZ5zZh5BvbRnxAilLO8wORslru/RkwWC5ilq7r3c5SSJihAW Bdo2JvHlpo6/ZoOn0scxvIT1QZ/Ek9rbG52fFHLIe4WkBsVuGkViFJxsG+s4L1MzCKgx TBAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=eSHkE7V37eRRB+OmAQ0+m49WziMhPUEY6R34db9KS7g=; b=UdcHwUcfmIe4NI0bxIW3zaS4MG4qJLV4G6jW2lzhYySkHapGrBdQR7mbRq/GI/Ll4P IIRvHVDLOWoO/ud4CUfg86Kkf4LhXLNLVND+4bOs9bIFRyQBCYTVeeqVsdeL2YT/wE32 zNvwMYnvMv5exMDdBL6eVj3oOfWhO5k4UOxY1fhWYJ/EHzzefcS5FMny1dHiBq0f3UJf ATzXcVayW8Gt7Jc8ak0u+tJTycFoBhGtRDJdxp21HvQWWz+yka/rU6Ra2CTaUCxRA5cp hvyqqc4EelOD1NgLD82dqOXI1WwNgxbFLueAFLf3zmqg7FYxMR4OCEgHJDtcia9DrIx1 Wuwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=LYeXwgcL; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g24-20020a633758000000b00476e21bc1bdsi867869pgn.162.2022.11.24.01.28.09; Thu, 24 Nov 2022 01:28:21 -0800 (PST) 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=@google.com header.s=20210112 header.b=LYeXwgcL; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbiKXJEG (ORCPT + 87 others); Thu, 24 Nov 2022 04:04:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbiKXJED (ORCPT ); Thu, 24 Nov 2022 04:04:03 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77AAA10CE8F for ; Thu, 24 Nov 2022 01:04:02 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id o7-20020a05600c510700b003cffc0b3374so782235wms.0 for ; Thu, 24 Nov 2022 01:04:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=eSHkE7V37eRRB+OmAQ0+m49WziMhPUEY6R34db9KS7g=; b=LYeXwgcLWttOK+PTUktaFMrFBa3suPjmv61D7Mt4V1wBx0WHj3M/BrOrlmmMnwoUhY 0y6yMjEdu60ceVb/+E9euPcn9cedsz6AUGhQorRP1Zq4qu+/fcYlxFbof6M/Mn1r7ix6 BwAvWjBPdbl1qF9nWLbFL64A6A13E3MKWeQYlI+Gme5RYfMaWff/r/8Yjq5u4pe6r7QH D6lWtvxoRcDOO1ce2l8S864c7nUBs/khNMND/HMDUXQeFj84WzY2KFxI9tDR2WByaTk+ Z7Yd64/GTmLkJHheav3I1dPQ+o2i4yTvWE/EvnhflODTshEWOij4ANS5FAlpA1UXKPQU BqmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eSHkE7V37eRRB+OmAQ0+m49WziMhPUEY6R34db9KS7g=; b=qYUyEZUsd9MXBrRnST4pEwZ6efALibiUf/g6AJ+4Ex9ksPQRZGjZWQDxHrOUiYU/Q4 Y5jD7PHjZ14suG/WoBChtOcUMn9MTL4hptGHnCQY/UGmnfuE0YMzYqP5CFSFoObWTEta ZHMkGcjJzWTm4XRqTjcY04N9AjUXxPKe39YIuURU8P3ZQHGfyHiBYyf7OVxRScF0mA0X GdgaxY4+Z1F1TDIswqwp1QW6JUVNq9WiNOq7SVOzAxPjJ8f+THOvTVR5f3ZpiASR6yxe Nrwy0PyoIfzUqwt0nS8zWTdsrHfVHTuTXZ1QtYOzLz5ckqWxAqxgwQ4+nHcEir9+7UDc +8WA== X-Gm-Message-State: ANoB5pmbWOeRQ0aAJvv/OjJLRuPew//NeeyR9tw9oDhFkuIZJefDDPjB 78YCqQPgN2p+bRFVW1ZqdyjhCYW1nQsHncYZ4t7eSQ== X-Received: by 2002:a05:600c:2108:b0:3cf:aae0:802a with SMTP id u8-20020a05600c210800b003cfaae0802amr13202014wml.112.1669280640770; Thu, 24 Nov 2022 01:04:00 -0800 (PST) MIME-Version: 1.0 References: <20221121234026.3037083-1-vipinsh@google.com> <20221121234026.3037083-3-vipinsh@google.com> <87bkozosvh.fsf@ovpn-194-185.brq.redhat.com> <87wn7koik7.fsf@ovpn-192-146.brq.redhat.com> In-Reply-To: <87wn7koik7.fsf@ovpn-192-146.brq.redhat.com> From: Vipin Sharma Date: Thu, 24 Nov 2022 01:03:24 -0800 Message-ID: Subject: Re: [PATCH v2 2/6] KVM: x86: hyper-v: Add extended hypercall support in Hyper-v To: Vitaly Kuznetsov Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, seanjc@google.com, pbonzini@redhat.com, dmatlack@google.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Thu, Nov 24, 2022 at 12:36 AM Vitaly Kuznetsov wrote: > > Vipin Sharma writes: > > > On Tue, Nov 22, 2022 at 8:29 AM Vitaly Kuznetsov wrote: > >> > >> Vipin Sharma writes: > >> > >> > +/* > >> > + * The TLFS carves out 64 possible extended hypercalls, numbered sequentially > >> > + * after the base capabilities extended hypercall. > >> > + */ > >> > +#define HV_EXT_CALL_MAX (HV_EXT_CALL_QUERY_CAPABILITIES + 64) > >> > + > >> > >> First, I thought there's an off-by-one here (and should be '63') but > >> then I checked with TLFS and figured out that the limit comes from > >> HvExtCallQueryCapabilities's response which doesn't include itself > >> (0x8001) in the mask, this means it can encode > >> > >> 0x8002 == bit0 > >> 0x8003 == bit1 > >> .. > >> 0x8041 == bit63 > >> > >> so indeed, the last one supported is 0x8041 == 0x8001 + 64 > >> > >> maybe it's worth extending the commont on where '64' comes from. > >> > > > > Yeah, I will expand comments. > > > >> > static void stimer_mark_pending(struct kvm_vcpu_hv_stimer *stimer, > >> > bool vcpu_kick); > >> > > >> > @@ -2411,6 +2417,9 @@ static bool hv_check_hypercall_access(struct kvm_vcpu_hv *hv_vcpu, u16 code) > >> > case HVCALL_SEND_IPI: > >> > return hv_vcpu->cpuid_cache.enlightenments_eax & > >> > HV_X64_CLUSTER_IPI_RECOMMENDED; > >> > + case HV_EXT_CALL_QUERY_CAPABILITIES ... HV_EXT_CALL_MAX: > >> > + return hv_vcpu->cpuid_cache.features_ebx & > >> > + HV_ENABLE_EXTENDED_HYPERCALLS; > >> > default: > >> > break; > >> > } > >> > @@ -2564,6 +2573,12 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) > >> > } > >> > goto hypercall_userspace_exit; > >> > } > >> > + case HV_EXT_CALL_QUERY_CAPABILITIES ... HV_EXT_CALL_MAX: > >> > + if (unlikely(hc.fast)) { > >> > + ret = HV_STATUS_INVALID_PARAMETER; > >> > >> I wasn't able to find any statement in TLFS stating whether extended > >> hypercalls can be 'fast', I can imagine e.g. MemoryHeatHintAsync using > >> it. Unfortunatelly, our userspace exit will have to be modified to > >> handle such stuff. This can stay for the time being I guess.. > >> > > > > I agree TLFS doesn't state anything about "fast" extended hypercall > > but nothing stops in future for some call to be "fast". I think this > > condition should also be handled by userspace as it is handling > > everything else. > > > > I will remove it in the next version of the patch. I don't see any > > value in verification here. > > The problem is that we don't currently pass 'fast' flag to userspace, > let alone XMM registers. This means that it won't be able to handle fast > hypercalls anyway, I guess it's better to keep your check but add a > comment saying that it's an implementation shortcoming and not a TLFS > requirement. > I think "fast" flag gets passed to the userspace via: vcpu->run->hyperv.u.hcall.input = hc.param; Yeah, XMM registers won't be passed, that will require userspace API change. I will keep the check and explain in the comments. > > > > >> > + break; > >> > + } > >> > + goto hypercall_userspace_exit; > >> > default: > >> > ret = HV_STATUS_INVALID_HYPERCALL_CODE; > >> > break; > >> > @@ -2722,6 +2737,7 @@ int kvm_get_hv_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid, > >> > > >> > ent->ebx |= HV_POST_MESSAGES; > >> > ent->ebx |= HV_SIGNAL_EVENTS; > >> > + ent->ebx |= HV_ENABLE_EXTENDED_HYPERCALLS; > >> > > >> > ent->edx |= HV_X64_HYPERCALL_XMM_INPUT_AVAILABLE; > >> > ent->edx |= HV_FEATURE_FREQUENCY_MSRS_AVAILABLE; > >> > >> Reviewed-by: Vitaly Kuznetsov > >> > >> -- > >> Vitaly > >> > > > > -- > Vitaly >