Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1106694pxv; Fri, 25 Jun 2021 05:44:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVt4w499kdmg0/HegImqg3zmGpFPa7si1Ot3irV6OC82VQ6U0fy25LTzQqQU2lAqbfme1r X-Received: by 2002:a17:906:4899:: with SMTP id v25mr10920074ejq.451.1624625083617; Fri, 25 Jun 2021 05:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624625083; cv=none; d=google.com; s=arc-20160816; b=KVF8f5drj404Y7nTAKTRUvlpENnPsLBOVfCNcbSazY1z4RFbjjEelVqcG88PQfXVE6 2T/QqP4KV03UIIzOj7B8VIfhz3dQm9aayrkd8L5C/3gJJm8vUgQGGm4bs1PdluDuF65K DYA7G5GdRBu0zx5nq/L9GICCdyF7ycMCzS9pkcqLGqDPX2ZOVfUiWZ4EoTnSnW3nxNlN 2Sxtdo/GhVpxFeRKk1Kg7U1aC7wgkedOFuhq+5CjqA+pc7FWJbawH2L5Ca2O5nz7aHPW 0EE2oRFhyzL5JiodQzNLoSgjo8jfvwpOqdEM6yddLh+Q4/FoDgYY0Co+DpxxGCcqLJxq h5OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=kUvHNoaJ8hCHdVSooVihvRmjh1gPNArcPRW12xQl1mg=; b=ec8eOV2yTi0D44B5fWqwT1K5JLQeMrq2euaOojbcfjrMoeh1SBTkORhhldc+83rgiX ZA18SucQlCgJilFJkOXXbNbC1endxsoaiYojDWKn+O5MC4vGaAT7OIQ21H4hykdNyXyp xVtTUBDjsI1ZVOXtAyoZ6fea5Lv2i7KnQesYUUsrfvawjjvOz7+vsGIbO6w+/Y5+i2ze xRgQFVG7CP4YLVgY7wfZK3kgCa/2R496OvhkkMDnRmksnPUWKArfhdjQ26vedu6KRYe0 W6oDo5fwaaG5QhMZWyAW9kaFP2ueGI1CfjBk0vZ2BXVrVJmvnE/JKETZdqnvumD7R++a WRKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wE8ezas2; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g13si740037edb.532.2021.06.25.05.44.19; Fri, 25 Jun 2021 05:44:43 -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=@linutronix.de header.s=2020 header.b=wE8ezas2; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbhFYMpL (ORCPT + 99 others); Fri, 25 Jun 2021 08:45:11 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:33180 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbhFYMpK (ORCPT ); Fri, 25 Jun 2021 08:45:10 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1624624968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kUvHNoaJ8hCHdVSooVihvRmjh1gPNArcPRW12xQl1mg=; b=wE8ezas2TzVU1H2UhFE2Qqluhh4R0PTGEDvLHCOLfcRKKkYieNL6kUqFABsgS5f4EHK1zn uC6Dc5WymQYokWHBTcQ7vf1nHgivxUMx3MUK8qNxxXYiKhX4fN8cZcZ22L+ci4srGoE++t Cfol40KPMcXP9wqkZEedvJaVZS72WRmr1OjJRWD0k5yLXogloXgfks2oOZLF/kYlSwpkjg 398u/kH2ZY5BlU7n2MuHxv2DzPSczvIGQb4mn4qTJyDTSMw5H7sbfci6fXpvzvWN8U78yS 5xSOzMhEoEMYxpBxjgI38RARtNkGfSGE+3hUrlsDAYNe+gwwR6zNiEuyzHG7UA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1624624968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kUvHNoaJ8hCHdVSooVihvRmjh1gPNArcPRW12xQl1mg=; b=fxzpnqDLxdWf/HUlsC3sYIU73rs4RLRvicSCFfizzTYMn/oKBBJAb5U77/sulc9bMlCoHc NgfQdpgeg1qmR/BA== To: "Tian\, Kevin" , Alex Williamson Cc: Jason Gunthorpe , "Dey\, Megha" , "Raj\, Ashok" , "Pan\, Jacob jun" , "Jiang\, Dave" , "Liu\, Yi L" , "Lu\, Baolu" , "Williams\, Dan J" , "Luck\, Tony" , "Kumar\, Sanjay K" , LKML , KVM , Kirti Wankhede , Peter Zijlstra , Marc Zyngier , Bjorn Helgaas Subject: RE: Virtualizing MSI-X on IMS via VFIO In-Reply-To: <87o8buuyfy.ffs@nanos.tec.linutronix.de> References: <8735t7wazk.ffs@nanos.tec.linutronix.de> <20210624154434.11809b8f.alex.williamson@redhat.com> <87o8buuyfy.ffs@nanos.tec.linutronix.de> Date: Fri, 25 Jun 2021 14:42:48 +0200 Message-ID: <87im22uncn.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 25 2021 at 10:43, Thomas Gleixner wrote: > On Fri, Jun 25 2021 at 05:21, Kevin Tian wrote: >> p.s. one question to Thomas. As Alex cited above, software must >> not modify the Address, Data, or Steering Tag fields of an MSI-X >> entry while it is unmasked. However this rule might be violated >> today in below flow: >> >> request_irq() >> __setup_irq() >> irq_startup() >> __irq_startup() >> irq_enable() >> unmask_irq() <<<<<<<<<<<<< >> irq_setup_affinity() >> irq_do_set_affinity() >> msi_set_affinity() // when IR is disabled >> irq_msi_update_msg() >> pci_msi_domain_write_msg() <<<<<<<<<<<<<< >> >> Isn't above have msi-x entry updated after it's unmasked? > > Dammit, I could swear that we had masking at the core or PCI level at > some point. Let me dig into this. Indeed, that code path does not check irq_can_move_pcntxt(). It doesn't blow up in our face by chance because of this: __setup_irq() irq_activate() unmask() irq_setup_affinity() irq_activate() assigns a vector based on the affinity mask so irq_setup_affinity() ends up writing the same data again pointlessly. For some stupid reason the ordering of startup/setup_affinity is the way it is for historical reasons. I tried to reorder it at some point but that caused failure on !x86 so I went back to the status quo. All other affinity settings happen with the interrupt masked because we do that from actual interrupt context via irq_move_masked_irq() which does the right thing. Let me fix that proper for the startup case. Thanks, tglx