Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp210933rdb; Mon, 18 Sep 2023 12:34:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaCKLvz0t6ZdQniRjkXYKZDfUPro/HW1W8l/2zcfmu/YiVLINovGVW33K926y/olhR79fP X-Received: by 2002:a17:902:efce:b0:1a9:b8c3:c2c2 with SMTP id ja14-20020a170902efce00b001a9b8c3c2c2mr9342180plb.37.1695065697691; Mon, 18 Sep 2023 12:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695065697; cv=none; d=google.com; s=arc-20160816; b=GK7+ae9YgUX+cfe84WjTJmXv3P2FTVCe+yOXZaK5HDgKqJTwHNNrRa9dLxC66Y9Kbj fT9sGPLqZl3v3jWHj2NuUxnyqcD/ZY4oMXWAwNm2+N15qvOEQRdC2+EI5hrMrkp1QYLm xHIJlYkDL3dewaF5eENA61HbPYm031Sw6XpxY8NkLRvmE6YofASEzMLiU588K3zy97cM 06f4ZoJzf7TWNLDfQ1SVYEtHnvqo49UNYTnlYu/Z5Y7cmbaRHxV1uwDKNo8Z0CTD/9pC E687D1/Q3pX62TFYPYDblI6EIPayATZgoYYnaxKMMB9US0GMmKiyHHX9zhpFLFOh1vHU 3faw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:references:cc:to:content-language:subject:reply-to :user-agent:mime-version:date:message-id:from:dkim-signature; bh=sLknf5KveUwbOgFiDLEqsKxezP26LvkH2sQEbrP8ZIM=; fh=h4plc5PkqfdB1P0f4+lC1NrOPiBu1ivLv+1T9qdDq3Q=; b=auEloJhyEQJy6UWhfWsy8d5yuTiolytk0lL/B5lfoVKWaFi1rZhyCaUh7AgtVXSTRW oVWddU4FNu3dxKpey8Z5xBtI8n5J37csJIaPIk2sYDIzlyVWrH+wmW4ZCsglBgm94w4i Z3nc6I0t17kMWvpDu8b5yh4AVqR50qZetjuKX7tpihdkrkgASxYIUk3wZ9rooL/deWxD VBsR80hgFbKGMtQDLkYowykRGr8ROzQW3ANRV4eV5r7ND0xM3abnWqApggklVgp23DQa B0RHwwNc8GOqTcG5u+NfOUlbkbKSM5qxtbPmj4oyfBHaiR1637NgBAAax79QjdEXM0du L9GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=efBjhhJ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id e1-20020a170902cf4100b001b53b6b029csi8587101plg.124.2023.09.18.12.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 12:34:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=efBjhhJ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 413F781FAD91; Mon, 18 Sep 2023 08:35:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbjIRPeV (ORCPT + 99 others); Mon, 18 Sep 2023 11:34:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbjIRPdw (ORCPT ); Mon, 18 Sep 2023 11:33:52 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4851E44; Mon, 18 Sep 2023 08:31:26 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-986d8332f50so633141566b.0; Mon, 18 Sep 2023 08:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695050879; x=1695655679; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:from:to:cc:subject:date:message-id:reply-to; bh=sLknf5KveUwbOgFiDLEqsKxezP26LvkH2sQEbrP8ZIM=; b=efBjhhJ0m5wynLUdIz6LJEHtJW+kU2BuurF2cqKh/Cyinb1GaAVDWnROwlcXmLs1Ob ptw/83rSzIJofPlhgAUVuhcVXi6jV15+apeyVCShN6hFzxaZXVNigr1/YFJC8j45BTE2 PrRDkifm0EJmfGBs0acIZCq4ulbcOFuYWPWk8TrPshB4w6URAZpPBUpHaO/m6fqXyyFo 7GSr7ZSDVJva4NbwaWfG7wFaf2vFd4+vnyBpUVf6N+Gznvc6BoH4WFRx06PFHEEmxf8J 218yvZJ5AhJuOEHsl0HOb41voW3KseVl9MHQXGHlDHP/YGOfFBGsGrSY2CIidGJW1S7/ U8Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695050879; x=1695655679; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sLknf5KveUwbOgFiDLEqsKxezP26LvkH2sQEbrP8ZIM=; b=AubXYaYs8CHodtO6Kk/YLBC/t7KRWxUru0hfGQcMOMG78Ug9pyabRmYpeXvUi4ngsU Ra0MQOFuYzi1ZpAXajr/wu8DoP+FQS8pfxPQKHXrtQHkkmTq7qnTKeErsRwHNxefk7Mt 7FQbxlFk2LqzQG5/Q49W31WROCUi0wVEe+zJ+bCMg2huo13i/FQG7l4eHVlMmcyS/3wF LbN/kveegKmHaMjwkB8tCOKrID5KsQrDVqovXyZhlf0tGcGYbPfasEx4DAs3R/FPJHAO iyYovJ6IjIfwCR3JP5uecwVGQne7QFdzojH+aaqIU0uZp9aq9+5bcCjr+b9pGiC8o2EL hcaQ== X-Gm-Message-State: AOJu0Yyo3AJVZAKdKA/KRnmcpt9rZuWeXDG2IPDE0dGuYZz6s9v3kw1g e6uw7VojiyDgcC6PuKWCvzEBsKETPweT3EWV X-Received: by 2002:a5d:6b03:0:b0:317:1b08:b317 with SMTP id v3-20020a5d6b03000000b003171b08b317mr7489032wrw.6.1695044469398; Mon, 18 Sep 2023 06:41:09 -0700 (PDT) Received: from [192.168.7.59] (54-240-197-236.amazon.com. [54.240.197.236]) by smtp.gmail.com with ESMTPSA id e1-20020a5d65c1000000b00315af025098sm12710014wrw.46.2023.09.18.06.41.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Sep 2023 06:41:08 -0700 (PDT) From: Paul Durrant X-Google-Original-From: Paul Durrant Message-ID: Date: Mon, 18 Sep 2023 14:41:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Reply-To: paul@xen.org Subject: Re: [PATCH v2 11/12] KVM: selftests / xen: don't explicitly set the vcpu_info address Content-Language: en-US To: David Woodhouse , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paul Durrant , Sean Christopherson , Paolo Bonzini References: <20230918112148.28855-1-paul@xen.org> <20230918112148.28855-12-paul@xen.org> <56dad458-8816-2de5-544e-a5e50c5ad2a2@xen.org> Organization: Xen Project In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:35:08 -0700 (PDT) X-Spam-Status: No, score=-2.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, 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 morse.vger.email On 18/09/2023 14:36, David Woodhouse wrote: > On Mon, 2023-09-18 at 14:26 +0100, Paul Durrant wrote: >> On 18/09/2023 14:21, David Woodhouse wrote: >>> On Mon, 2023-09-18 at 11:21 +0000, Paul Durrant wrote: >>>> From: Paul Durrant >>>> >>>> If the vCPU id is set and the shared_info is mapped using HVA then we can >>>> infer that KVM has the ability to use a default vcpu_info mapping. Hence >>>> we can stop setting the address of the vcpu_info structure. >>> >>> Again that means we're not *testing* it any more when the test is run >>> on newer kernels. Can we perhaps set it explicitly, after *half* the >>> tests are done? Maybe to a *different* address than the default which >>> is derived from the Xen vcpu_id? And check that the memcpy works right >>> when we do? >>> >> >> Ok. The VMM is currently responsible for that memcpy. Are you suggesting >> we push that into KVM too? > > Ah OK. > > Hm, maybe we should? > > What happened before in the case where interrupts were being delivered, > and the vcpu_info address was changed. > > In Xen, I guess it's effectively atomic? Some locking will mean that > the event channel is delivered to the vcpu_info either *before* the > memcpy, or *after* it, but never to the old address after the copy has > been done, so that the event (well the index of it) gets lost? > > In KVM before we did the automatic placement, it was the VMM's problem. > > If there are any interrupts set up for direct delivery, I suppose the > VMM should have *removed* the vcpu_info mapping before doing the > memcpy, then restored it at the new address? I may have to check qemu > gets that right. > > Then again, it's a very hard race to trigger, given that a guest can > only set the vcpu_info once. So it can move it from the shinfo to a > separate address and attempt to trigger this race just that one time. > > But in the case where auto-placement has happened, and then the guest > sets an explicit vcpu_info location... are we saying that the VMM must > explicitly *unmap* the vcpu_info first, then memcpy, then set it to the > new location? Or will we handle the memcpy in-kernel? > Well, if the VMM is using the default then it can't unmap it. But setting a vcpu_info *after* enabling any event channels would be a very odd thing for a guest to do and IMO it gets to keep the pieces if it does so. Paul