From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EB0EC433FE for ; Thu, 24 Nov 2022 09:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbiKXJEH (ORCPT ); Thu, 24 Nov 2022 04:04:07 -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-Google-Smtp-Source: AA0mqf6x/ExsicSzIsXDel57lNri4Nr6Rn5qOOTdUHWDHAIoH+gIEH9T7LCfz9Epl6npOtEKL/DyWoeDA2/2pjnVpVk= 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" 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 >