Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2021028rwb; Fri, 19 Aug 2022 13:42:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lYFco7HB9PJcKsHwnD9k7mCxdV0n7M8bg3SBIRw7AK1WM5013kgFBqNTbEdAS9T+mmsDB X-Received: by 2002:a50:eb8b:0:b0:446:16cf:cfa8 with SMTP id y11-20020a50eb8b000000b0044616cfcfa8mr6750632edr.418.1660941773442; Fri, 19 Aug 2022 13:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660941773; cv=none; d=google.com; s=arc-20160816; b=A631e+Ee3ACRxFyayy/HiV8SIfLPNH7eyDvehA/U+ek95r1Ep4MjE8ZUBhcxdqbUuA HbtTSS+hAg4615AOfoFxO6QHy/3hS1J3hpUzpN6c5M7KeAgfpXObrkGk0n4/1C4teWqt Bmp3xAZmzMLviW4mycHsCdoUiVYM61KJRqVEA9tGmARFEgmsCKHvLSZwAUQ+dstz4rHc /dAsh/Ad7aDPAZyZpGACepeAYgTJ/N7FdMkcMXGJQ0j50Kw762JzpSgsJeSBFE2DiWwv YqDsA5kh4w+++b7CNNwmWoUcnr5FTwHKzsuetiiV9SXR+SC+rrt+xyLk6FWotJqhk7/C 4now== 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=OdVRHW5dgn9+ZFv7Dx3d9MQVdeaggjviefmhBuLYccY=; b=fbsaZDGF1Kd7y1JLQRBOvIuKdFdctTrvZ6o8KrnY72MWu62PlFGxka9+B7Iz8wDiy0 4zdjmjO661bshj0kJvb1wiEVNuhwUxLsHtblOF0AMXxEo9S88uqmFPyaILzBdiLEqgZB Q07IORktGseBHjdRfm7tjp56+SAIthUNVuxPoeVzwMjZtB9Jlowtg/iSg8brH1//rCzU UPX5+NAaBURRDUIkXwe2CQFEWRihYhD2JzQi5i9GR8wbAh7vNel5+ZP+QSBONh6AJJ1A W6vca1PmVdR67mbtJKq9ev3hZKEKReoi/4E0Q7yc4aCcaPxN5o2fhheQ+DNBvHIJZFa6 hf6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=KLiHLmUn; 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 x21-20020a170906805500b0072b4cba9671si2950147ejw.186.2022.08.19.13.42.27; Fri, 19 Aug 2022 13:42:53 -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=@google.com header.s=20210112 header.b=KLiHLmUn; 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 S1351430AbiHST2D (ORCPT + 99 others); Fri, 19 Aug 2022 15:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349705AbiHST16 (ORCPT ); Fri, 19 Aug 2022 15:27:58 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F6BE81B2F for ; Fri, 19 Aug 2022 12:27:56 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id bh13so4429725pgb.4 for ; Fri, 19 Aug 2022 12:27:56 -0700 (PDT) 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; bh=OdVRHW5dgn9+ZFv7Dx3d9MQVdeaggjviefmhBuLYccY=; b=KLiHLmUnTwUW4nPAcccokb8rqDM7RaZKR3tAhfpWrqa4fyUZ11fQGnRCahlJbMSNkc K7onznVTAcTPdJ5ctU5qfok0xiXA4RUZWWeXukjQhEL0KrbtzmRpe90Uuw2GudQ6cB3z wqidMjhzn3TYXU35oygksNUgU3fknacc64G2XK3+HLTw5IWBs6csGTW6/65ggSWB/q94 VV1NbgwFLjrAIvYqiN/GSEoDRheHm2Jcs0J12eYCvBM3w1EYrjOcPA4TzdFyaz7+hBZg W08yNzJhuyiH6ybAoXgAL2/XGKRMYk/cdwhxrx/frztCzW3qlKJK1yFKPYJyVcVN9uzT Z1KQ== 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; bh=OdVRHW5dgn9+ZFv7Dx3d9MQVdeaggjviefmhBuLYccY=; b=1DIyRp4EBP0Yhz6r93YhbhVGqhotUBp5uk4l8DgvOmrNQuQh8beqrHYsTBMwrd17hL aWZ+QO07RPPbBS3XIs0WrcWUB/VODuIT24Kmupg+6Zi6+p1uGmrUmZVYWlRY/RIX+xT9 h9o5/CPFBPM5zyHY99Pu1cBebC8n4H1p2BQKU3JYQ2zmyq4/pxOyl+8ozOZcfjNE47Si j18UsYVuRQanNZGaKBtPb8p4imSuQQ3Y8e7KKJdMgIQQ9RjoKr48/CZWaqFm+dSlhrqq /wGUdzCdPOSwIOyQThLZknbUnFRhsAmd9nXY2tYU7ZzpRAZ5sX9LXmNWIenn1UMcwGEP H7AA== X-Gm-Message-State: ACgBeo38jrBQ1duavcILj4CFXQj1myxeNhB3y44+77gWTS762usHS8PP Py5cP2Ws0DhYEguNiQkgObU6yaGYJh6YTqb8qrXpUA== X-Received: by 2002:a65:5941:0:b0:41d:a203:c043 with SMTP id g1-20020a655941000000b0041da203c043mr7317812pgu.483.1660937275721; Fri, 19 Aug 2022 12:27:55 -0700 (PDT) MIME-Version: 1.0 References: <20220810152033.946942-1-pgonda@google.com> <20220810152033.946942-11-pgonda@google.com> In-Reply-To: <20220810152033.946942-11-pgonda@google.com> From: Vishal Annapurve Date: Fri, 19 Aug 2022 12:27:44 -0700 Message-ID: Subject: Re: [V3 10/11] KVM: selftests: Add ucall pool based implementation To: Peter Gonda Cc: kvm list , LKML , Marc Orr , Sean Christopherson , Michael Roth , Tom Lendacky , Joerg Roedel , Mingwei Zhang , Paolo Bonzini , andrew.jones@linux.dev 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, T_SCC_BODY_TEXT_LINE,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 Wed, Aug 10, 2022 at 8:20 AM Peter Gonda wrote: > ... > + > +static struct ucall *ucall_alloc(void) > +{ > + struct ucall *uc = NULL; > + int i; > + > + if (!use_ucall_pool) > + goto out; > + > + for (i = 0; i < KVM_MAX_VCPUS; ++i) { > + if (!atomic_test_and_set_bit(i, ucall_pool->in_use)) { > + uc = &ucall_pool->ucalls[i]; > + memset(uc->args, 0, sizeof(uc->args)); > + break; > + } > + } > +out: > + return uc; > +} > + > +static inline size_t uc_pool_idx(struct ucall *uc) > +{ > + return uc->hva - ucall_pool->ucalls; > +} > + > +static void ucall_free(struct ucall *uc) > +{ > + if (!use_ucall_pool) > + return; > + > + clear_bit(uc_pool_idx(uc), ucall_pool->in_use); > +} > > void ucall(uint64_t cmd, int nargs, ...) > { > - struct ucall uc = {}; > + struct ucall *uc; > + struct ucall tmp = {}; This steps seems to result in generating instructions that need SSE support on x86: struct ucall tmp = {}; movaps %xmm0,0x20(%rsp) movaps %xmm0,0x30(%rsp) movaps %xmm0,0x40(%rsp) movaps %xmm0,0x50(%rsp) This initialization will need proper compilation flags to generate instructions according to VM configuration. > va_list va; > int i; > > - WRITE_ONCE(uc.cmd, cmd); > + uc = ucall_alloc(); > + if (!uc) > + uc = &tmp; > + > + WRITE_ONCE(uc->cmd, cmd); > > nargs = min(nargs, UCALL_MAX_ARGS); > > va_start(va, nargs); > for (i = 0; i < nargs; ++i) > - WRITE_ONCE(uc.args[i], va_arg(va, uint64_t)); > + WRITE_ONCE(uc->args[i], va_arg(va, uint64_t)); > va_end(va); > > - ucall_arch_do_ucall((vm_vaddr_t)&uc); > ...