Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp554217pxu; Fri, 4 Dec 2020 09:33:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJykBxlLImegWc6SY8HLi5LDHpqvIL+uTNgb3qwcqwr/yrzS8/JKT03iSSiK5B9KXkQ5iAR3 X-Received: by 2002:a17:906:c097:: with SMTP id f23mr8452026ejz.136.1607103183532; Fri, 04 Dec 2020 09:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607103183; cv=none; d=google.com; s=arc-20160816; b=PlVxLajP2f1qoxuBpWCU7fThiBGvsbKjHoyPdPElkopzhia9YN74V5nasEd+9zSEjK qBuOKBoyfplSlqh+zsg7/Sy5XNIBR02eRtwV2s2vd1SX3ThjF9GWFujW8igdCexbdvbA f5aZ7iF2WTLueTLPFGgCYd7Td5s0k10x3KHD6BXxSl1ULDBrKBaE3j4zB6GSQAVdx9jP gX++509Rw3LCBL6G6dOdCsThhlh8FxEOpO+KDxfNdTrG4Yjfdu8NKuUL9pkv3p1w4Dh0 djWd7uA0QNOxnT/tXXbI/MoE6z+FvfDuA1piuuw73zr3jV+yKx+L6gkZim1MLiYu1A+h ebMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C83LWVZ8wM91AdWAS0iA3r1viy6kVdAOxGG9S1jtaCw=; b=rwaBUeWl58bAzlf6ALmPPXLfAcwMbbiyjG5rv2q9wrOgk/Uj5xrvwt4Q/KIRmle349 nLQUgoEpVzIa4lMgWUXxJDI51zo4ZfbWkCxunsvbTwgTKqL8MtMHaJiNo2xaKDhFk/K0 2dHnLCRXe2l3gyK+ivDrSkC8MfAv+iPdv8MeJotyXJQZrzXqCraCYHjoJAbqRPWOjgI/ e4215/E6A8Cxhf1fjooG9HNRFPgpBHBoFLJjxnXrdXghsAhy94mZ+56LZocXbc6+9vII 2X+NMIIq9IQsZ1/gSV89Kg56Ev4BmDq/Swq5TAYUwkFGU1e3RUOMN+i3zrYrlEvMcLkM pbqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iJAUPmwW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si1682892ejx.39.2020.12.04.09.32.39; Fri, 04 Dec 2020 09:33:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iJAUPmwW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728583AbgLDRa5 (ORCPT + 99 others); Fri, 4 Dec 2020 12:30:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726021AbgLDRa5 (ORCPT ); Fri, 4 Dec 2020 12:30:57 -0500 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C832C061A4F for ; Fri, 4 Dec 2020 09:30:11 -0800 (PST) Received: by mail-pj1-x1044.google.com with SMTP id o7so3546490pjj.2 for ; Fri, 04 Dec 2020 09:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=C83LWVZ8wM91AdWAS0iA3r1viy6kVdAOxGG9S1jtaCw=; b=iJAUPmwWEnaAhg3wVRqh7oUcyTgWd+UHbESFOsFKDVfqajgfIROKPFQ5GD3OU+xa99 Jl3jC+WqpIsbkSbHw/wROs7jt7qUdrlmAp5EEseFWwhknRSyQQJrHkiSxJSWBujBv5TZ 7zhwhuArunV5D0CHnsEzlrVBVopSEiBeOYSKmSK8SJWyif03QcE0FIu0cTxZmcPzBgJm Pnc3BsqDFAjAJounHoX0+dImC/5neswOWxsc5tDWdxI9ngeqt1ULE2o+4DlAW6Gkayg1 +7ieOETFbxJ7E6S7Tb1xRFdv1LS+r9l0jA3+JcuzuFQbbSYKINDifFz1seUopnH18UrJ N0TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=C83LWVZ8wM91AdWAS0iA3r1viy6kVdAOxGG9S1jtaCw=; b=OAINUo+7vG1lWCYFQrvCjXC0fmDBYJpqHILNGQGSQiaqkD3CtUPcGXW99MC3r+QVrU wMitMwgOdi7sdlr3fX8Oq7ay3o9LhjzD0hp4gHVFCz2MW0RsMlxEm8sO7nDT6G+OkN/u dGYcYOwTDqIsiYClgOtryoiFcS4VN9DoP6PA64p12rRszBiGF37dkUrzXutU+yHQc1S/ dEbkx8VQV8n4pLO7nBEC2NmHgCryAb7l523ZCh8rIAobG7t5emdWx9/hxJK5+Kf9F95b ji8irrNtFe+ZKNzTurAzWqcWN62cYYWcK4Iu4fvlFuaYPLcuow8CnAkdmKZkEm4dt62n Gh7g== X-Gm-Message-State: AOAM530bywuNCgrX5c3fveCAsx1Rrpo0A2zWkq2cWdPmgNhVrM5FPIVF uZ9JlpB7W3VDL6vbpdOQi6j3kw== X-Received: by 2002:a17:90a:154a:: with SMTP id y10mr5170231pja.6.1607103010205; Fri, 04 Dec 2020 09:30:10 -0800 (PST) Received: from google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) by smtp.gmail.com with ESMTPSA id h11sm5728667pfn.27.2020.12.04.09.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 09:30:09 -0800 (PST) Date: Fri, 4 Dec 2020 09:30:02 -0800 From: Sean Christopherson To: David Woodhouse Cc: Ankur Arora , Joao Martins , Boris Ostrovsky , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH RFC 03/39] KVM: x86/xen: register shared_info page Message-ID: References: <20190220201609.28290-1-joao.m.martins@oracle.com> <20190220201609.28290-4-joao.m.martins@oracle.com> <2d4df59d-f945-32dc-6999-a6f711e972ea@oracle.com> <896dc984-fa71-8f2f-d12b-458294f5f706@oracle.com> <58db65203b9464f6f225f4ef97c45af3c72cf068.camel@infradead.org> <6ea92fe2-4067-d0e0-b716-16d39a7a6065@oracle.com> <8c92b2f3a8e8829ec85d22091b2fe84794f12f78.camel@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8c92b2f3a8e8829ec85d22091b2fe84794f12f78.camel@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 03, 2020, David Woodhouse wrote: > On Wed, 2020-12-02 at 12:32 -0800, Ankur Arora wrote: > > > On IRC, Paolo told me that permanent pinning causes problems for memory > > > hotplug, and pointed me at the trick we do with an MMU notifier and > > > kvm_vcpu_reload_apic_access_page(). > > > > Okay that answers my question. Thanks for clearing that up. > > > > Not sure of a good place to document this but it would be good to > > have this written down somewhere. Maybe kvm_map_gfn()? > > Trying not to get too distracted by polishing this part, so I can > continue with making more things actually work. But I took a quick look > at the reload_apic_access_page() thing. > > AFAICT it works because the access is only from *within* the vCPU, in > guest mode. > > So all the notifier has to do is kick all CPUs, which happens when it > calls kvm_make_all_cpus_request(). Thus we are guaranteed that all CPUs > are *out* of guest mode by the time... > > ...er... maybe not by the time the notifier returns, because all > we've done is *send* the IPI and we don't know the other CPUs have > actually stopped running the guest yet? > > Maybe there's some explanation of why the actual TLB shootdown > truly *will* occur before the page goes away, and some ordering > rules which mean our reschedule IPI will happen first? Something > like that ideally would have been in a comment in in MMU notifier. KVM_REQ_APIC_PAGE_RELOAD is tagged with KVM_REQUEST_WAIT, which means that kvm_kick_many_cpus() and thus smp_call_function_many() will have @wait=true, i.e. the sender will wait for the SMP function call to finish on the target CPUs.