Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1742967pxb; Thu, 28 Oct 2021 09:14:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCgruOLhzBw1HFsxJvkE1PIkTJ29+ukqmm2W5372Kryf0QB3/wD04esDNMMXvpPr0QnC2E X-Received: by 2002:a17:902:aa03:b0:13f:a07e:da04 with SMTP id be3-20020a170902aa0300b0013fa07eda04mr4792773plb.80.1635437644804; Thu, 28 Oct 2021 09:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635437644; cv=none; d=google.com; s=arc-20160816; b=fKTcIRemTrX7DP6VvxsYjenwMdpoGR+H4wUevhXvGzQlMuD2lgQWO4d7mp5VoXP+Jq Gze0++wJNRKWXjFl9h0qo6GNDNlS3ikuco4WwjAufOEaBvIbzxmA/Y7lQwJ9OUuO/ial LhJRKrr2kgK/Vvt+STDjNri7ExbQApZezvYWKA7TexjFeoyFdyYkGqrYP+79GSjxFByW wzqIfR6B6jmxB3EOhc2u3L8lEm5HEpQIHJ5H4rEW7IhRzZ+h+meUqH6qiZ2/RnEvVzkx 5HXpLbSeN06rzMoXLeId66gh71HDnL8vmjoevUdlbaJ14g6zS2947QM74WqlSYgfxiME ZF2g== 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=uDFUXcWiQOAZszlFDFiKgSiJL9HB/WuFg2qPOmsqC9E=; b=HOzcq1Ys7noQk2e13U3JSCAcbCwFS7KyzB+iya645oDby/4SOf8RObiF8Y0Onxtjzg NheMIzK2gtS3sClkvn0z8zINH8TDHBsQK3qOfvVsOBgA+3M4WjKk/le+TUECmsNrPdCa bnuhgtIR6iio186Hk4oFBLPiKJJVm4m82wSMIiefemR3yix4KzrmU9qnDls494MCKhnp 6iREtQy0HcmaPx04YaECyn3VlebbUFbtI1vcw/iU8jjudFhNHO3EpcOYiSkmYCPd7WrF WYUIgL/OOENgmdrTZ98CvBNHGjkLVT1/AEBdcGcJ7A7Z0a3Yyic5sc8LdqIfg1Gdl6BM IKvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=s8JT5njE; 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 b7si4261290pgm.415.2021.10.28.09.13.50; Thu, 28 Oct 2021 09:14:04 -0700 (PDT) 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=20210112 header.b=s8JT5njE; 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 S230264AbhJ1QOg (ORCPT + 99 others); Thu, 28 Oct 2021 12:14:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbhJ1QOf (ORCPT ); Thu, 28 Oct 2021 12:14:35 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2958C061745 for ; Thu, 28 Oct 2021 09:12:08 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id x66so6398725pfx.13 for ; Thu, 28 Oct 2021 09:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uDFUXcWiQOAZszlFDFiKgSiJL9HB/WuFg2qPOmsqC9E=; b=s8JT5njEusSpDvvGXpDQ9LZlankma9a4yiSWD9KOohfnBHlxyPNl/U/08pekLcb/bC ovoSobTTd28f9TmLEDOEfxcyphCFmhjuM9+ON0HPn4qn8BCTN2ldIPxu2jDowg4XqJu6 3xH28lP4FssgtQ0ca7hD6ajCl1FxkivUDYuXRLmLx2Yi3tCCzZXargRA7TY8R9VN5f+Z OVvgBrcUFyQ3a4VjcEcymihbaDJ3t1+Gwm46k3BuLJXPbEryRKF1JBLikEHoHCefGv/7 I7zNR4Q9EXiCvnW7HnxhjPhNdV9zeEX0aTdpBRV58BMvHDUDx6AGdT+87VVv7qJ97TcC uARw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uDFUXcWiQOAZszlFDFiKgSiJL9HB/WuFg2qPOmsqC9E=; b=Mq8LxcTGej+QCI+cixcvrMHzTDgkQ6bjJscq7+8ELfOUmd4PHQFLbIt3vGoJeFcnzU i6oJc/a/UYRmKfWwgTFVdibTvwuQNJjiEvH9I5cf7EYZGfErKhpEWF+djVuWqMC8jLDs BdSsGP4ZNKKPDlpegINVYSeoInIebqZCCBW9UK4g0XBgoysu4xNEqz8/UacUVMO1L6R9 3s1OWDG4p6HWTjqoP03kmWbkzZyiZKlGm7fLX4Z/PLaE6fia29GfybYJX08cI+HsLIbE CuDnAeYJryjdxXdDMuRg6Y8/YxqXkEdTXYEtffjkLlPT9ZhKvEVFsG8OdvPLLpD5Izh9 2llQ== X-Gm-Message-State: AOAM531m3uJHgL33fBEQnEoDNNVRTXsIrqC0Cssi+XFsPwc6hfGJphzw 3N0BJ2vVhsu06cCnSZ+kXWcBAA== X-Received: by 2002:a05:6a00:1709:b0:47e:493e:ca5f with SMTP id h9-20020a056a00170900b0047e493eca5fmr4461870pfc.60.1635437528216; Thu, 28 Oct 2021 09:12:08 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id f7sm4329616pfv.152.2021.10.28.09.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 09:12:07 -0700 (PDT) Date: Thu, 28 Oct 2021 16:12:04 +0000 From: Sean Christopherson To: Maxim Levitsky Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , Atish Patra , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , Oliver Upton , Jing Zhang Subject: Re: [PATCH v2 27/43] KVM: VMX: Move Posted Interrupt ndst computation out of write loop Message-ID: References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-28-seanjc@google.com> <643d9c249b5863f04290a6f047ea1a2d98bd75f9.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <643d9c249b5863f04290a6f047ea1a2d98bd75f9.camel@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 28, 2021, Maxim Levitsky wrote: > On Fri, 2021-10-08 at 19:12 -0700, Sean Christopherson wrote: > > Hoist the CPU => APIC ID conversion for the Posted Interrupt descriptor > > out of the loop to write the descriptor, preemption is disabled so the > > CPU won't change, and if the APIC ID changes KVM has bigger problems. > > > > No functional change intended. > > Is preemption always disabled in vmx_vcpu_pi_load? vmx_vcpu_pi_load is called > from vmx_vcpu_load, which is called indirectly from vcpu_load which is called > from many ioctls, which userspace does. In these places I don't think that > preemption is disabled. Preemption is disabled in vcpu_load() by the get_cpu(). The "cpu" param that's passed around the vcpu_load() stack is also why I think it's ok to _not_ assert that preemption is disabled in vmx_vcpu_pi_load(); if preemption is enabled, "cpu" is unstable and thus the entire "load" operation is busted. #define get_cpu() ({ preempt_disable(); __smp_processor_id(); }) #define put_cpu() preempt_enable() void vcpu_load(struct kvm_vcpu *vcpu) { int cpu = get_cpu(); __this_cpu_write(kvm_running_vcpu, vcpu); preempt_notifier_register(&vcpu->preempt_notifier); kvm_arch_vcpu_load(vcpu, cpu); put_cpu(); } EXPORT_SYMBOL_GPL(vcpu_load);