Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp243125pxb; Mon, 13 Sep 2021 18:09:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytR47CkUVQVPBpgq3mVrUHILjIZBtbZQRNLoBadL+2IdOO91iuoJDy7oRUQT3vdUcVgZuD X-Received: by 2002:a05:6e02:1b89:: with SMTP id h9mr1495204ili.297.1631581780755; Mon, 13 Sep 2021 18:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631581780; cv=none; d=google.com; s=arc-20160816; b=jKYmpXUTFRpiqXnStq5ljXq7xJQU9gFZGRifQh1ZsrwDleMQko7jL5a3NP2ycP3sAL xecn/65b3mGwTzGwgJ68NKvQSrtklvW98olL2PeQCy5WN/HO+sjSzxxE9LTHOvL97gFg GfIrq4yvAbyyKPNFJqEq3KP3beDuXOnWiO71yx2HUEI/MAAXr8JD/i8y1jlIT64B3lyi FErNX3w01J6Vs+1dCLJK27lhrQqSnS2KmXdHN2yT+fY0T5cinjO1zeseTmLV6tlUlx94 2eo0xYqbpQrd2evqAmPQfqMnB9LKZYPCS7wBSbvBvbdVpftd2uMSuGedTxr3P9XxwMTJ kUcg== 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=hlpZvCk21PRwAK2AssPWCacRS5dlgslqLeUme/k+iMw=; b=C5Hnyl8ntnSJhMY/wCNXssXGeX8G70caYNDkuyYpBoV+D2r5Jgha6dERNZRX+/Y4BX Z5RGWYnmmlDkFxV+Xv1K8Dar6CCA0Muz+3jJr3wsB6B6m/S2Jb6PWXDh2GndcNwY7G+n qGqLgAldWvmWgQkLgXSNlyaosCasKctWfeiDh53IFh+0A4A7SdzteBRg61V5nqiST1ud bY+FsuAExamawzPxArV77rIQ02ugIgUZNBGcRV7BZL9LgQp4rbnmWRd6WhwWgJWkvLVb mKM/LAlvwMP2VNk9v2XXjKYzwDfa/CC0r9eiEvTIETe88+Jatky1Ia0qFbe+c9nDiWC3 YqGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H5JxGe5O; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si8004006ioc.79.2021.09.13.18.09.29; Mon, 13 Sep 2021 18:09:40 -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=@redhat.com header.s=mimecast20190719 header.b=H5JxGe5O; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244584AbhIMUzf (ORCPT + 99 others); Mon, 13 Sep 2021 16:55:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60673 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244428AbhIMUzd (ORCPT ); Mon, 13 Sep 2021 16:55:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631566456; 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=hlpZvCk21PRwAK2AssPWCacRS5dlgslqLeUme/k+iMw=; b=H5JxGe5OArwC+am0XfDj6N1MhPEX3j5vgkyObmX35eK1dUvEVqpLzvPAWlpdrk/X7hin3p jp7VNtX386HgdB69vd+m8W00VGTrSOdBKPlP024iDHkP6/1HNq6hckNr8oef0GxojdiCBj OVPaXgnWmKI8sXb4VveITz5uLK/jZPw= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-PLhFaAltNGiBiegZEPOs1w-1; Mon, 13 Sep 2021 16:54:15 -0400 X-MC-Unique: PLhFaAltNGiBiegZEPOs1w-1 Received: by mail-wr1-f69.google.com with SMTP id r15-20020adfce8f000000b0015df1098ccbso1855296wrn.4 for ; Mon, 13 Sep 2021 13:54:14 -0700 (PDT) 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=hlpZvCk21PRwAK2AssPWCacRS5dlgslqLeUme/k+iMw=; b=xn/we5xcHuDKHlwMPTG4JsI0YuuDgoYL7lSzJnwPPzIsLNUxXXA28KpxOh6j/v1/nN 67tBoFxlsDmKqLclAcFX4cqSbqxWRMk2nEbbIZ99PUMBcHdfnIgxnciD9VYsazRP11Th 83kUZu+aoh0fMWafGoP8l5IN0A1WH9u/daU9t9vPe9OkNUShZK1rc9ibP0uW8Y3Ib5vo 8I1mb9byu9aAv87PWettr3uNlUF7D5clHf8CiTDU+/+OtdQng7nj9UcrMJYPnYnZO1/q qA4bjveQNKgInQs3k/FXwdNjMtf+PiTW0y8IlJg0V43yB8dx4W6eUznghyx4Re5hjre9 ZnKw== X-Gm-Message-State: AOAM532qwN9WXDrhAs6UfPSXXDfzFfyl91sGJ0HNtfgimU+JzZJTBMie rAagc5b1sZa9AxClVFXsSX3blk6kPkse1iJMYDtL3p1rKU01Zk0nnMI8gx7XCGm5Lc6tb/y3XfJ Kn6PAdCMcH8VNujEvZ+/p+2CJ X-Received: by 2002:a5d:63d2:: with SMTP id c18mr14416343wrw.311.1631566453986; Mon, 13 Sep 2021 13:54:13 -0700 (PDT) X-Received: by 2002:a5d:63d2:: with SMTP id c18mr14416326wrw.311.1631566453828; Mon, 13 Sep 2021 13:54:13 -0700 (PDT) Received: from redhat.com ([2.55.151.134]) by smtp.gmail.com with ESMTPSA id w1sm7747752wmc.19.2021.09.13.13.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 13:54:13 -0700 (PDT) Date: Mon, 13 Sep 2021 16:54:08 -0400 From: "Michael S. Tsirkin" To: Thomas Gleixner Cc: Jason Wang , virtualization , linux-kernel , "Hetzelt, Felicitas" , "kaplan, david" , Konrad Rzeszutek Wilk , pbonzini , Andi Kleen , Dan Williams , "Kuppuswamy, Sathyanarayanan" , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , Bjorn Helgaas , Richard Henderson , Thomas Bogendoerfer , James E J Bottomley , Helge Deller , "David S . Miller" , Arnd Bergmann , Jonathan Corbet , Peter H Anvin , Dave Hansen , Tony Luck , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , X86 ML Subject: Re: [PATCH 6/9] virtio_pci: harden MSI-X interrupts Message-ID: <20210913164934-mutt-send-email-mst@kernel.org> References: <20210913055353.35219-1-jasowang@redhat.com> <20210913055353.35219-7-jasowang@redhat.com> <20210913015711-mutt-send-email-mst@kernel.org> <20210913022257-mutt-send-email-mst@kernel.org> <20210913023626-mutt-send-email-mst@kernel.org> <20210913024153-mutt-send-email-mst@kernel.org> <87bl4wfeq1.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bl4wfeq1.ffs@tglx> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 13, 2021 at 09:38:30PM +0200, Thomas Gleixner wrote: > On Mon, Sep 13 2021 at 15:07, Jason Wang wrote: > > On Mon, Sep 13, 2021 at 2:50 PM Michael S. Tsirkin wrote: > >> > But doen't "irq is disabled" basically mean "we told the hypervisor > >> > to disable the irq"? What extractly prevents hypervisor from > >> > sending the irq even if guest thinks it disabled it? > >> > >> More generally, can't we for example blow away the > >> indir_desc array that we use to keep the ctx pointers? > >> Won't that be enough? > > > > I'm not sure how it is related to the indirect descriptor but an > > example is that all the current driver will assume: > > > > 1) the interrupt won't be raised before virtio_device_ready() > > 2) the interrupt won't be raised after reset() > > If that assumption exists, then you better keep the interrupt line > disabled until virtio_device_ready() has completed started not completed. device is allowed to send config interrupts right after DRIVER_OK status is set by virtio_device_ready. > and disable it again > before reset() is invoked. That's a question of general robustness and > not really a question of trusted hypervisors and encrypted guests. We can do this for some MSIX interrupts, sure. Not for shared interrupts though. > >> > > > > > > +void vp_disable_vectors(struct virtio_device *vdev) > >> > > > > > > { > >> > > > > > > struct virtio_pci_device *vp_dev = to_vp_device(vdev); > >> > > > > > > int i; > >> > > > > > > @@ -34,7 +34,20 @@ void vp_synchronize_vectors(struct virtio_device *vdev) > >> > > > > > > synchronize_irq(vp_dev->pci_dev->irq); > > Don't you want the same change for non-MSI interrupts? We can't disable them - these are shared. > Thanks, > > tglx