Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp588079rdb; Tue, 31 Oct 2023 16:59:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFR/3iBZglKeahUF4zvYO5y+Z3BFg0BJy3hGOns3mg71ojyNtVRgy8MQi+zHD5tLCktXJ5v X-Received: by 2002:a05:6a00:2b8c:b0:6bf:15fb:4b32 with SMTP id dv12-20020a056a002b8c00b006bf15fb4b32mr1270683pfb.8.1698796745841; Tue, 31 Oct 2023 16:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698796745; cv=none; d=google.com; s=arc-20160816; b=OEf5S2Hv9EuVWwnZqbUF7rCRYw8oBAC5QrNktsy/nAYm2J2hNrE/TLaHgNNd/cThj1 vSiVcbwjiPIjgPDH/gCsCddP6B5Nc4SBqiV0D8+EHEuuuDzjZ9EjHtXVgfIfcbWybN/+ e12bqFlkYPfU5kAnMTwQyiaUebmqJcXUuIwlu9VhQot4aq61Fm7k7gLwo2isFKEwYoG5 Y/cJebXVtzofSOVEpf78MNix/uPGmYJAazPd/rCY6hAGSkq4Yaty7zwxgdFMybNZIUyW yKGzUbCbF1IqRutphwAZ6WD+/DLDzau6ArlQWZSEeYMf4WOyPZaq395fsrADWS7JqoO/ i8zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=9i9Iv3jiMg/J1qGB5P5psVE2uSLqd7nXP+oyj+C4sSw=; fh=I+bdMHoZtW/6AWgkh1jvohDNc7xunPa+smgsvLS+U8A=; b=y4egMN7o712tKikCdV6PcKYggAr7Rnz15J8RmABuh101/pLwYBSauGsQsPQLYifkvY 2ug/B6HluyuTS4VDoEyrDZPP9fdot/fRRZPcYUtXXf2FneyfpAthep3aIL2BaadA4RHa FRfRPIv47e+1I3jI4OMf3Y1pBP40bvO6Z01fvRZDl7tworveMTIRodnrcmPCKXY8bAN+ /ouaKgJXudbu3TS/Yx384IcSaMoLoIbEAHBTPLnXcBxXjWoa36u00Ub4V7XBZVQcUPq/ W2Nn536Wmf3sABcwipXAlvEVBJFIq+gGsyFieW85AUw/Qe0yHGTovUtSASLqn9E04Rfq TUZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZLKDBjWB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id g38-20020a631126000000b00589336ba9f7si1756812pgl.822.2023.10.31.16.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 16:59:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZLKDBjWB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E20F580BA7D8; Tue, 31 Oct 2023 16:59:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344309AbjJaX67 (ORCPT + 99 others); Tue, 31 Oct 2023 19:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235192AbjJaX65 (ORCPT ); Tue, 31 Oct 2023 19:58:57 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E3C0E8 for ; Tue, 31 Oct 2023 16:58:55 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da03c5ae220so328343276.1 for ; Tue, 31 Oct 2023 16:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698796735; x=1699401535; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9i9Iv3jiMg/J1qGB5P5psVE2uSLqd7nXP+oyj+C4sSw=; b=ZLKDBjWBM/QlML7IUgghULULuNQQrZ67XTste20kFGvnbzJ7Sd4MtgaHIVINXx056j BmVcornZLsQUA6+NS9cvzs3L9VDurK2AbLAnOqB0meHhSLbJpoQchu5Jbn/0oFZTLRz0 1cOvbeBKgk87cnucW/N+nb6u2poqdqnNagG1lSeZ+/fVooDdrpID5a9Pq1yD9eSa7TRr BkGv32fcAosWc87mC3XYMna1dCeCPfmPeOcNtfkbYEAjPViFSHxgYTn4IAQZfYbhCu5C tc/5EQrlvOiAB5tVbmx7StgB+crtUdz4l+qUm9AlP150Q6KA7bx87IIsHTLp8EgBzmzO +Avw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698796735; x=1699401535; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9i9Iv3jiMg/J1qGB5P5psVE2uSLqd7nXP+oyj+C4sSw=; b=IA9NwQa3i7QG4Tf4Bgmg+c65w4q0euRhEm/FEP8YjD8gZF0wNv69KhKwO1E4geHxgz d8EU+gvAdqre2WVS298ufvi6MPAipmUpu9iLG7WdiEIsxGmV81/iQxKm0e0JbvMQp0TI oQy20akfY5YYUkoCvfv5R8cRIEpdpF6A09k5EMr0CjFTS0/MkCtROKhJYQYCQOcho/d8 ZqOMXTd027JwUUFOl5I7ZzSw6owWTiA05oQJDu2p6J1U2usdcRMqrsprqs7t1S6RtZjY U0urcfCSlMcY6PqWxMuhKV2fhW9SYelDdsPQ/JiH+TVvdhtgTkOq6qrxiktl+KsBWgbH dnVw== X-Gm-Message-State: AOJu0YxivpT8Jdn1Qtyn3+NNNTII7uO3Oo7cFRUVhQg9DCnvgVi0xE/T iOaMlnSOtwrrBJgeVgdHSTars+xP3SE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:264f:0:b0:da3:b467:af07 with SMTP id m76-20020a25264f000000b00da3b467af07mr11219ybm.2.1698796734909; Tue, 31 Oct 2023 16:58:54 -0700 (PDT) Date: Tue, 31 Oct 2023 16:58:53 -0700 In-Reply-To: <20231002095740.1472907-12-paul@xen.org> Mime-Version: 1.0 References: <20231002095740.1472907-1-paul@xen.org> <20231002095740.1472907-12-paul@xen.org> Message-ID: Subject: Re: [PATCH v7 11/11] KVM: xen: allow vcpu_info content to be 'safely' copied From: Sean Christopherson To: Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Durrant , David Woodhouse , David Woodhouse , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 16:59:03 -0700 (PDT) On Mon, Oct 02, 2023, Paul Durrant wrote: > From: Paul Durrant > > If the guest sets an explicit vcpu_info GPA then, for any of the first 32 > vCPUs, the content of the default vcpu_info in the shared_info page must be > copied into the new location. Because this copy may race with event > delivery (which updates the 'evtchn_pending_sel' field in vcpu_info) we > need a way to defer that until the copy is complete. Nit, add a blank link between paragraphs. > Happily there is already a shadow of 'evtchn_pending_sel' in kvm_vcpu_xen > that is used in atomic context if the vcpu_info PFN cache has been > invalidated so that the update of vcpu_info can be deferred until the > cache can be refreshed (on vCPU thread's the way back into guest context). > So let's also use this shadow if the vcpu_info cache has been > *deactivated*, so that the VMM can safely copy the vcpu_info content and > then re-activate the cache with the new GPA. To do this, all we need to do > is stop considering an inactive vcpu_info cache as a hard error in > kvm_xen_set_evtchn_fast(). Please, please try to write changelogs that adhere to the preferred style. I get that the preferred style likely doesn't align with what you're used to, but the preferred style really doesn't help me get through reviews quicker. > diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c > index aafc794940e4..e645066217bb 100644 > --- a/arch/x86/kvm/xen.c > +++ b/arch/x86/kvm/xen.c > @@ -1606,9 +1606,6 @@ int kvm_xen_set_evtchn_fast(struct kvm_xen_evtchn *xe, struct kvm *kvm) > WRITE_ONCE(xe->vcpu_idx, vcpu->vcpu_idx); > } > > - if (!vcpu->arch.xen.vcpu_info_cache.active) > - return -EINVAL; > - Hmm, maybe move this check after the "hard" error checks and explicitly do: return -EWOULDBLOCK That way it's much more obvious that this patch is safe. Alternatively, briefly explain what happens if the cache is invalid in the changelog. > if (xe->port >= max_evtchn_port(kvm)) > return -EINVAL; > > -- > 2.39.2 >