From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Christopherson Date: Wed, 24 Aug 2022 15:32:07 +0000 Subject: [PATCH v4 5/6] KVM: selftests: Make arm64's MMIO ucall multi-VM friendly In-Reply-To: References: <20220824032115.3563686-1-seanjc@google.com> <20220824032115.3563686-6-seanjc@google.com> Message-ID: List-Id: To: kvm-riscv@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed, Aug 24, 2022, Oliver Upton wrote: > Hi Sean, > > On Wed, Aug 24, 2022 at 03:21:14AM +0000, Sean Christopherson wrote: > > +/* > > + * Sync a global pointer to the guest that has a per-VM value, in which case > > + * writes to the host copy of the "global" must be serialized (in case a test > > + * is being truly crazy and spawning multiple VMs concurrently). > > + */ > > Do we even care about writes to the host's copy of the global pointer? > I don't see how the host pointer is used beyond serializing writes into > a guest. > > IOW, it looks as though we could skip the whole global illusion > altogether and write straight into guest memory. *sigh* This exact thought crossed my mind when I first looked at this code, but somehow I couldn't come up with the obvious solution of using a temporary on-stack variable to hold the desired value. Something like this should work. #define write_guest_global(vm, g, val) ({ \ typeof(g) *_p = addr_gva2hva(vm, (vm_vaddr_t)&(g)); \ typeof(g) _val = val; \ \ memcpy(_p, &(_val), sizeof(g)); \ }) 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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37D97C32793 for ; Wed, 24 Aug 2022 15:32:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7D3974D28B; Wed, 24 Aug 2022 11:32:15 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9COcPCCOhcmB; Wed, 24 Aug 2022 11:32:14 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 6A5274D281; Wed, 24 Aug 2022 11:32:14 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id EAA6E4D27C for ; Wed, 24 Aug 2022 11:32:13 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZPR-puxyOvQ3 for ; Wed, 24 Aug 2022 11:32:12 -0400 (EDT) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id CD7754D277 for ; Wed, 24 Aug 2022 11:32:12 -0400 (EDT) Received: by mail-pg1-f177.google.com with SMTP id w13so10262161pgq.7 for ; Wed, 24 Aug 2022 08:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=UZnSHBhLdMOKtTsvoHUMcnhpm7mRfzt47Yx1rwe6TYo=; b=ZLLZ1sQgjDCQZCR6iPbiV+dqJNVFlqF98MJZe+fMBspnKcQ1UNH5o3QOOx9DF7zBKA 4NTZQU8BcU6LZoqrr74W5W2rChziUMwFRSTTGrC513hiwIJ39DS6AjzTbmueQdO2STE0 t09KkGjDmYbiMqWw8kicU5n4mAAvwqsvfR4L8kRTE4YxLV1mXG0u1f2lpXeh4xy6gdFe Wv/tpw2JwZvjKVZthEj5z4x1vSTS+evVhLMdntp8ICLZ2wM3nwRTCYJP9MatbCfSirsX fcVMxPNOyrjAZQmeXvPefg+H+k8Jj7MzekfI//odudIng7UsH3Qp7cbIUqf69180zIUj AbYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=UZnSHBhLdMOKtTsvoHUMcnhpm7mRfzt47Yx1rwe6TYo=; b=UlzKobW4D2RCkPw69wgkZDQciW6JsnuYFMBMrhFuXmmPCID/iVCKVGYBxVPOaaz2pH 2uD2oqKuSM7G3IH58k0yEwFZp2udu0y6mZFQzC1oqEDPBO9HAB1N+Y8DWMNWVBbSZgtk CiqiUW3z3yzKmDtkGSSqP9cKlhxUJ0ghj2vuOjGXXzFQgRFLEaK8GHjTVZA6H88jWNXm S5zYsX1rN6gqyQZoEDAZXKhjwZYkWcDnrDRxmKOGdBKF2zPTIYsWkVi6ZSvbQkE9gSip V2b6idXmvwFATnVX+Z8DEm/9BazKFZ8wO2gnJ/nvjlC/O+WmOtiYh+Qp9fDi878lk4yr XH3w== X-Gm-Message-State: ACgBeo0W171g3/TX4yLvg+UCVRqKOHSuSpAZiDgJiE42r72+3/NVDV6H DbzDGcA4GJbUAqQi0Zcl0RXCpw== X-Google-Smtp-Source: AA6agR5QWDXsHQ6VWlCNVAAXtH2sA1tM24WXPqXY0c9+lwwnmRBfulv0M4b7+RjikXl1y2MhtN3W7Q== X-Received: by 2002:a63:8343:0:b0:42b:3b1a:89f6 with SMTP id h64-20020a638343000000b0042b3b1a89f6mr859171pge.26.1661355131607; Wed, 24 Aug 2022 08:32:11 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id d5-20020a17090ad3c500b001f53705ee92sm1567101pjw.6.2022.08.24.08.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 08:32:11 -0700 (PDT) Date: Wed, 24 Aug 2022 15:32:07 +0000 From: Sean Christopherson To: Oliver Upton Subject: Re: [PATCH v4 5/6] KVM: selftests: Make arm64's MMIO ucall multi-VM friendly Message-ID: References: <20220824032115.3563686-1-seanjc@google.com> <20220824032115.3563686-6-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: kvm@vger.kernel.org, David Hildenbrand , Tom Rix , Paul Walmsley , llvm@lists.linux.dev, Colton Lewis , linux-riscv@lists.infradead.org, Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, Janosch Frank , Marc Zyngier , Peter Gonda , Christian Borntraeger , Albert Ou , Nathan Chancellor , Atish Patra , Andrew Jones , linux-arm-kernel@lists.infradead.org, Nick Desaulniers , linux-kernel@vger.kernel.org, Palmer Dabbelt , kvm-riscv@lists.infradead.org, Paolo Bonzini X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Wed, Aug 24, 2022, Oliver Upton wrote: > Hi Sean, > > On Wed, Aug 24, 2022 at 03:21:14AM +0000, Sean Christopherson wrote: > > +/* > > + * Sync a global pointer to the guest that has a per-VM value, in which case > > + * writes to the host copy of the "global" must be serialized (in case a test > > + * is being truly crazy and spawning multiple VMs concurrently). > > + */ > > Do we even care about writes to the host's copy of the global pointer? > I don't see how the host pointer is used beyond serializing writes into > a guest. > > IOW, it looks as though we could skip the whole global illusion > altogether and write straight into guest memory. *sigh* This exact thought crossed my mind when I first looked at this code, but somehow I couldn't come up with the obvious solution of using a temporary on-stack variable to hold the desired value. Something like this should work. #define write_guest_global(vm, g, val) ({ \ typeof(g) *_p = addr_gva2hva(vm, (vm_vaddr_t)&(g)); \ typeof(g) _val = val; \ \ memcpy(_p, &(_val), sizeof(g)); \ }) _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1A99C00140 for ; Wed, 24 Aug 2022 15:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ECeMUjCFrz3+zCdqRTIihALq4Ty/ligkNbOWxvW8Qyo=; b=UZEyrggVyspY7B gFypWQSZyfIV4k9DDGqaIG4DoIb4unxCrnXy7HvbvUHkUk1XXj+7MxF8laU2DUi9OdrRENr4afo2D G3dVTXZY2/QiKQ4w/IWrBByGFsfstcpkd6Q4REJgm8V/8McOO0wg8pHVnT56jVIFE6lrlXfykPzw+ ax+X44DNdRVWRj10J8YVz/VdkYYDYkVShLgpdwdAwtWoYMoxTFmIH/hHzzU/idRRNrugeBpA7+fuO hyUTITN035ZXcGkLY9ukOaZeWQTShRhCOfYULsIB8/IgSIl2ypV7jonNUFTmkTrl/ugsr9i81eTY6 thmxsgMDsOiETgFwDS0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQsMd-00E4YF-7Q; Wed, 24 Aug 2022 15:32:19 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQsMa-00E4Uf-Qo for linux-riscv@lists.infradead.org; Wed, 24 Aug 2022 15:32:18 +0000 Received: by mail-pg1-x52f.google.com with SMTP id w13so10262160pgq.7 for ; Wed, 24 Aug 2022 08:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=UZnSHBhLdMOKtTsvoHUMcnhpm7mRfzt47Yx1rwe6TYo=; b=ZLLZ1sQgjDCQZCR6iPbiV+dqJNVFlqF98MJZe+fMBspnKcQ1UNH5o3QOOx9DF7zBKA 4NTZQU8BcU6LZoqrr74W5W2rChziUMwFRSTTGrC513hiwIJ39DS6AjzTbmueQdO2STE0 t09KkGjDmYbiMqWw8kicU5n4mAAvwqsvfR4L8kRTE4YxLV1mXG0u1f2lpXeh4xy6gdFe Wv/tpw2JwZvjKVZthEj5z4x1vSTS+evVhLMdntp8ICLZ2wM3nwRTCYJP9MatbCfSirsX fcVMxPNOyrjAZQmeXvPefg+H+k8Jj7MzekfI//odudIng7UsH3Qp7cbIUqf69180zIUj AbYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=UZnSHBhLdMOKtTsvoHUMcnhpm7mRfzt47Yx1rwe6TYo=; b=XqTxBt0XR+9f2nO5zd5HbVz3I6MmiDzrKlltAZLsaa7V21IhcNQmlwFogUXPSdVTs2 SdEKHbIKjWjDC643RAqGzCDji7ADMH76FqQETSjjUaUhRZoytPZFlZGPk4ZiIqNJZG0z jyTZsgBVZodiOLDEvjcbEfQKGocGa/SaYl9qfMNpnGR88gAaoo8KuItSD3ANNTyTlTXm +sQxWMNU5bfR/BByaeSghpFs5xP+wOrugFv7n1bXrHAueZ49Yd68kBuIujHgApuL5K1k VOASycXJ3zoMCDKthP4TKpAwIICUpMA1hhf1huuHCHmlQE2uTtzakoRAOxUz5h3bLwaR u7VA== X-Gm-Message-State: ACgBeo1wxGDt/JJ3tQPZtJsUGRtfV+7XLJAMMh61IbMzNYwAuGbKpsqK rMJq0tBNFqpfQrUxjEmsJBOlNQ== X-Google-Smtp-Source: AA6agR5QWDXsHQ6VWlCNVAAXtH2sA1tM24WXPqXY0c9+lwwnmRBfulv0M4b7+RjikXl1y2MhtN3W7Q== X-Received: by 2002:a63:8343:0:b0:42b:3b1a:89f6 with SMTP id h64-20020a638343000000b0042b3b1a89f6mr859171pge.26.1661355131607; Wed, 24 Aug 2022 08:32:11 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id d5-20020a17090ad3c500b001f53705ee92sm1567101pjw.6.2022.08.24.08.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 08:32:11 -0700 (PDT) Date: Wed, 24 Aug 2022 15:32:07 +0000 From: Sean Christopherson To: Oliver Upton Cc: Paolo Bonzini , Marc Zyngier , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Nathan Chancellor , Nick Desaulniers , James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Tom Rix , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Colton Lewis , Peter Gonda , Andrew Jones Subject: Re: [PATCH v4 5/6] KVM: selftests: Make arm64's MMIO ucall multi-VM friendly Message-ID: References: <20220824032115.3563686-1-seanjc@google.com> <20220824032115.3563686-6-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220824_083216_885393_7815CF00 X-CRM114-Status: GOOD ( 15.78 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Wed, Aug 24, 2022, Oliver Upton wrote: > Hi Sean, > > On Wed, Aug 24, 2022 at 03:21:14AM +0000, Sean Christopherson wrote: > > +/* > > + * Sync a global pointer to the guest that has a per-VM value, in which case > > + * writes to the host copy of the "global" must be serialized (in case a test > > + * is being truly crazy and spawning multiple VMs concurrently). > > + */ > > Do we even care about writes to the host's copy of the global pointer? > I don't see how the host pointer is used beyond serializing writes into > a guest. > > IOW, it looks as though we could skip the whole global illusion > altogether and write straight into guest memory. *sigh* This exact thought crossed my mind when I first looked at this code, but somehow I couldn't come up with the obvious solution of using a temporary on-stack variable to hold the desired value. Something like this should work. #define write_guest_global(vm, g, val) ({ \ typeof(g) *_p = addr_gva2hva(vm, (vm_vaddr_t)&(g)); \ typeof(g) _val = val; \ \ memcpy(_p, &(_val), sizeof(g)); \ }) _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F7387E for ; Wed, 24 Aug 2022 15:32:12 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id q63so1100171pga.9 for ; Wed, 24 Aug 2022 08:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=UZnSHBhLdMOKtTsvoHUMcnhpm7mRfzt47Yx1rwe6TYo=; b=ZLLZ1sQgjDCQZCR6iPbiV+dqJNVFlqF98MJZe+fMBspnKcQ1UNH5o3QOOx9DF7zBKA 4NTZQU8BcU6LZoqrr74W5W2rChziUMwFRSTTGrC513hiwIJ39DS6AjzTbmueQdO2STE0 t09KkGjDmYbiMqWw8kicU5n4mAAvwqsvfR4L8kRTE4YxLV1mXG0u1f2lpXeh4xy6gdFe Wv/tpw2JwZvjKVZthEj5z4x1vSTS+evVhLMdntp8ICLZ2wM3nwRTCYJP9MatbCfSirsX fcVMxPNOyrjAZQmeXvPefg+H+k8Jj7MzekfI//odudIng7UsH3Qp7cbIUqf69180zIUj AbYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=UZnSHBhLdMOKtTsvoHUMcnhpm7mRfzt47Yx1rwe6TYo=; b=iqKo+Ukn8YSVLs5qjspaxOQhjGFnFGkZ886S8Z+YkicX7KLCwLggK3lU+TxQupUzby scAbozteQmvfoMBQxIBBAJmjHoYtAbkRca263vXow0Qe0nbIbUvE1bu2g7JGH3Ax5hjX UJIhgH3q4xEtb6qz9z09SwxU7MA6MPlumpiOGxuLQ6nDmjWpHtVq0mfxKudrIW6miryH t0EqI0zRJO+GJrvX9x3iJ+2MsP70RO7dh8qNYFCoo/UBTkEqmnQmwPrP4o60NFEj/rFD /rxt9WUG39xq10vQq08Axf6qtaIaZ88ue9KIn2cxGhb+ogOzg6Qr8cb+txq6NZnNWYM0 LFIg== X-Gm-Message-State: ACgBeo3mnG8qlFEXfa7J+rteTr+T/7NqqsFVJtpY/dcEQmJ3Pgr8NUhM t8/HOeJFrAy8fCQT7AStj7r1wQ== X-Google-Smtp-Source: AA6agR5QWDXsHQ6VWlCNVAAXtH2sA1tM24WXPqXY0c9+lwwnmRBfulv0M4b7+RjikXl1y2MhtN3W7Q== X-Received: by 2002:a63:8343:0:b0:42b:3b1a:89f6 with SMTP id h64-20020a638343000000b0042b3b1a89f6mr859171pge.26.1661355131607; Wed, 24 Aug 2022 08:32:11 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id d5-20020a17090ad3c500b001f53705ee92sm1567101pjw.6.2022.08.24.08.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 08:32:11 -0700 (PDT) Date: Wed, 24 Aug 2022 15:32:07 +0000 From: Sean Christopherson To: Oliver Upton Cc: Paolo Bonzini , Marc Zyngier , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Nathan Chancellor , Nick Desaulniers , James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Tom Rix , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Colton Lewis , Peter Gonda , Andrew Jones Subject: Re: [PATCH v4 5/6] KVM: selftests: Make arm64's MMIO ucall multi-VM friendly Message-ID: References: <20220824032115.3563686-1-seanjc@google.com> <20220824032115.3563686-6-seanjc@google.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Aug 24, 2022, Oliver Upton wrote: > Hi Sean, > > On Wed, Aug 24, 2022 at 03:21:14AM +0000, Sean Christopherson wrote: > > +/* > > + * Sync a global pointer to the guest that has a per-VM value, in which case > > + * writes to the host copy of the "global" must be serialized (in case a test > > + * is being truly crazy and spawning multiple VMs concurrently). > > + */ > > Do we even care about writes to the host's copy of the global pointer? > I don't see how the host pointer is used beyond serializing writes into > a guest. > > IOW, it looks as though we could skip the whole global illusion > altogether and write straight into guest memory. *sigh* This exact thought crossed my mind when I first looked at this code, but somehow I couldn't come up with the obvious solution of using a temporary on-stack variable to hold the desired value. Something like this should work. #define write_guest_global(vm, g, val) ({ \ typeof(g) *_p = addr_gva2hva(vm, (vm_vaddr_t)&(g)); \ typeof(g) _val = val; \ \ memcpy(_p, &(_val), sizeof(g)); \ }) 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60F78C00140 for ; Wed, 24 Aug 2022 15:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f6+k5DLtAEGSqkagU1GNQRWb4BquNlRBmcWSt0cfq7M=; b=k7St+8n7aHH2dq GeIdUABcm5sndQ5figcthdC6VaurJ+xiYXEkGtsOKLtdABHSWC+bIfF/mD2G0DeMk4JqzuuhH4glc Vd46LIvi5RQyOw5Ukz9s9YyjWN97TDGBbq+rmCm3e70aVMA2c3ZP+ul+W1oeAaMZizrCRramk/578 4mFmTjDYEUvCSBQwQrZacMOwCUKLveBetto46exa79FU29ekfxiIlUzfVNR2xdFwDm4L6RNw/wJYO e5ONTVSXuF6mKGZOQ3POlhHWcQINB4X8wDIQlj8zj8NpYDEEi/I6q7QBi4uVgv8LBrpIOBcKlE2W9 p0cDi+hNa9Xo858wjY1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQsMf-00E4Z2-O1; Wed, 24 Aug 2022 15:32:21 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQsMa-00E4Ug-TC for linux-arm-kernel@lists.infradead.org; Wed, 24 Aug 2022 15:32:19 +0000 Received: by mail-pg1-x531.google.com with SMTP id q9so6289320pgq.6 for ; Wed, 24 Aug 2022 08:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=UZnSHBhLdMOKtTsvoHUMcnhpm7mRfzt47Yx1rwe6TYo=; b=ZLLZ1sQgjDCQZCR6iPbiV+dqJNVFlqF98MJZe+fMBspnKcQ1UNH5o3QOOx9DF7zBKA 4NTZQU8BcU6LZoqrr74W5W2rChziUMwFRSTTGrC513hiwIJ39DS6AjzTbmueQdO2STE0 t09KkGjDmYbiMqWw8kicU5n4mAAvwqsvfR4L8kRTE4YxLV1mXG0u1f2lpXeh4xy6gdFe Wv/tpw2JwZvjKVZthEj5z4x1vSTS+evVhLMdntp8ICLZ2wM3nwRTCYJP9MatbCfSirsX fcVMxPNOyrjAZQmeXvPefg+H+k8Jj7MzekfI//odudIng7UsH3Qp7cbIUqf69180zIUj AbYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=UZnSHBhLdMOKtTsvoHUMcnhpm7mRfzt47Yx1rwe6TYo=; b=x11s3rurEcgvx691kIhjbcsTbUq0TdjF+gpDJDe1hEJ0DVDAfre/8fdZ9AT0eEwvW2 FA8PrfooM172IsuBOq5RKV2VJMTqn5c4W4srb4JqcRr+3dmNzzj2KGLB4o+R9XOEMFcE hcqfv1FS2uOaWe6FZb9Gnqxwebz7rpoq5rEe/A1N6adEu57ADEtgqMrHQCkofBG1+PAu wZoyWUv+szgGx0gRrFCDAgGHhesJC8eE/ZvyJRhWRRjhlxyqVcio+8WMGYTWTM1K/TFj XMLPcElXjUEBzofZxPolDeLUsId/h2H9Lcmxdh4yWG8drpco46nOsuaS8lhTcLRjz8Fy /v4g== X-Gm-Message-State: ACgBeo0p96QQt77Rs+W4hyNM7+yMJ0iMgXmhyEr68LjIVkb6KyW798HG bVjs+l6v+hk4HX34nXYHtRXb6w== X-Google-Smtp-Source: AA6agR5QWDXsHQ6VWlCNVAAXtH2sA1tM24WXPqXY0c9+lwwnmRBfulv0M4b7+RjikXl1y2MhtN3W7Q== X-Received: by 2002:a63:8343:0:b0:42b:3b1a:89f6 with SMTP id h64-20020a638343000000b0042b3b1a89f6mr859171pge.26.1661355131607; Wed, 24 Aug 2022 08:32:11 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id d5-20020a17090ad3c500b001f53705ee92sm1567101pjw.6.2022.08.24.08.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 08:32:11 -0700 (PDT) Date: Wed, 24 Aug 2022 15:32:07 +0000 From: Sean Christopherson To: Oliver Upton Cc: Paolo Bonzini , Marc Zyngier , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Nathan Chancellor , Nick Desaulniers , James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Tom Rix , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Colton Lewis , Peter Gonda , Andrew Jones Subject: Re: [PATCH v4 5/6] KVM: selftests: Make arm64's MMIO ucall multi-VM friendly Message-ID: References: <20220824032115.3563686-1-seanjc@google.com> <20220824032115.3563686-6-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220824_083216_952530_F517DC81 X-CRM114-Status: GOOD ( 17.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Aug 24, 2022, Oliver Upton wrote: > Hi Sean, > > On Wed, Aug 24, 2022 at 03:21:14AM +0000, Sean Christopherson wrote: > > +/* > > + * Sync a global pointer to the guest that has a per-VM value, in which case > > + * writes to the host copy of the "global" must be serialized (in case a test > > + * is being truly crazy and spawning multiple VMs concurrently). > > + */ > > Do we even care about writes to the host's copy of the global pointer? > I don't see how the host pointer is used beyond serializing writes into > a guest. > > IOW, it looks as though we could skip the whole global illusion > altogether and write straight into guest memory. *sigh* This exact thought crossed my mind when I first looked at this code, but somehow I couldn't come up with the obvious solution of using a temporary on-stack variable to hold the desired value. Something like this should work. #define write_guest_global(vm, g, val) ({ \ typeof(g) *_p = addr_gva2hva(vm, (vm_vaddr_t)&(g)); \ typeof(g) _val = val; \ \ memcpy(_p, &(_val), sizeof(g)); \ }) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel