From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C6B6C433EF for ; Wed, 27 Oct 2021 22:11:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 367D560240 for ; Wed, 27 Oct 2021 22:11:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 367D560240 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vYl9wAOsWj1zGK+YBW0y/A711zrUG2ZVPyUwRPcRggY=; b=3tgHihSEgRCY3j +w+nUoOU647oc5PMUJz2qKW8adbA6W8gEazLvdY3vBT46H+8lJ1hQ9W8lzIrx6ucQR3Lk+LBFrD+d /o9KSjVw7vzxFQq9b9uEwUQdSM0CgvHGJauFhxZvQFb9bQ4qGRupXHSyY939HBdP2wLraG73dmTM4 71uI+FZM+2xDcVBMf55H5pJnmSjTANSrkxH+WLQBULvEzbVSiQ+I2fq56Y7ohWCNsnYHyyPtL8Xod eZwQf3hQRi/zdgHd9B88hMCLW/wAwn0tEP1mPPB+Wpe6ZntRN8cSQgnWkPZBjfhp/zl7fvd+a0IaE 3RkUUg5p7luzxqbTaPdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfr7I-006NLO-Gu; Wed, 27 Oct 2021 22:09:52 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfr7E-006NKC-En for linux-arm-kernel@lists.infradead.org; Wed, 27 Oct 2021 22:09:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635372586; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vPTDsq9RY16fTCCoMhEcqKhkYxR/hT5AGgzHMhJ6ojY=; b=IAMcVO2ZcNaowSZesQXSUgOlxjCPhD3/D2HXDPcFh1EopPVgQ9wn/KzZ5ozVodm9vqYUFk TLB0aam8jfFrNaskFFG31AK/zseq6GosXpGUChclsiesCnNx+uv9OssMo6XO+h+p4p+Dyi 8CR1nGCKg1wkY2PNBXQg3WXk38p5uNQ= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-604-lCgxOz61NxO_lcjUgke5Kw-1; Wed, 27 Oct 2021 18:09:45 -0400 X-MC-Unique: lCgxOz61NxO_lcjUgke5Kw-1 Received: by mail-ed1-f72.google.com with SMTP id v21-20020a056402349500b003dfa41553f3so75807edc.11 for ; Wed, 27 Oct 2021 15:09:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=vPTDsq9RY16fTCCoMhEcqKhkYxR/hT5AGgzHMhJ6ojY=; b=g1ZU4Mi91ssbgvPNreKLiSxmm3p3fvdtkdCW4B3OfZzljTZo+VfETJglX814YfmrDD QqaJhcpyIMWn82AIwAQb5w6/hdQsnqWkJiVoNkt/Qs4VSagURMNQjeZyvA2LmOXySKFj 9EKHewnzRv46FrU2dEMz82dEMISRw7ReD9OEgxPq+lQ9qXyTYcVGD4fks6CxAbcvG9D4 FGyMTPJQKty3BKtKXYx9rTC7ydpGnkxCosIB3jFpKV5eRWnb+n+tExyujzFR6K2/qwyA WQSyViDgYQLjMs409hOJqT2aA3b/sfQssnwC4Ij70k5AhgOI5vCPOKy2cZRilc+3XdJ8 Z9tg== X-Gm-Message-State: AOAM530fjnJDfjdsd7aKZY67FLD9KDWkJyRMzS+724VTcRWWwpR9oNor jfaZHbCKF5RvDGaGvNb1oBhPEVgnoRjwYKOQYcbhoLMo2G41inVK72SvQ9eOhgVnBaTs9kzOPrL YVURZC0rqSBi/w6WVvNQvXhbaM27XVQp7NAg= X-Received: by 2002:a17:906:3f95:: with SMTP id b21mr341846ejj.368.1635372584296; Wed, 27 Oct 2021 15:09:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoBx4vKjR30o+Kgjfdb4KsDUE6yjTUINxxdU8F5+6sRGk01DyvRy4bEl13EnJPgWSCV29mNQ== X-Received: by 2002:a17:906:3f95:: with SMTP id b21mr341810ejj.368.1635372584078; Wed, 27 Oct 2021 15:09:44 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id a9sm675279edm.31.2021.10.27.15.09.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Oct 2021 15:09:43 -0700 (PDT) Message-ID: Date: Thu, 28 Oct 2021 00:09:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH v2 39/43] KVM: VMX: Don't do full kick when triggering posted interrupt "fails" To: Sean Christopherson Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , 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 References: <20211009021236.4122790-1-seanjc@google.com> <20211009021236.4122790-40-seanjc@google.com> <335822ac-b98b-1eec-4911-34e4d0e99907@redhat.com> From: Paolo Bonzini In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211027_150948_638353_656652F1 X-CRM114-Status: GOOD ( 11.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 27/10/21 18:04, Sean Christopherson wrote: >>> + /* >>> + * The smp_wmb() in kvm_make_request() pairs with the smp_mb_*() >>> + * after setting vcpu->mode in vcpu_enter_guest(), thus the vCPU >>> + * is guaranteed to see the event request if triggering a posted >>> + * interrupt "fails" because vcpu->mode != IN_GUEST_MODE. >> >> What this smp_wmb() pair with, is the smp_mb__after_atomic in >> kvm_check_request(KVM_REQ_EVENT, vcpu). > > I don't think that's correct. There is no kvm_check_request() in the relevant path. > kvm_vcpu_exit_request() uses kvm_request_pending(), which is just a READ_ONCE() > without a barrier. Ok, we are talking about two different set of barriers. This is mine: - smp_wmb() in kvm_make_request() pairs with the smp_mb__after_atomic() in kvm_check_request(); it ensures that everything before the request (in this case, pi_pending = true) is seen by inject_pending_event. - pi_test_and_set_on() orders the write to ON after the write to PIR, pairing with vmx_sync_pir_to_irr and ensuring that the bit in the PIR is seen. And this is yours: - pi_test_and_set_on() _also_ orders the write to ON before the read of vcpu->mode, pairing with vcpu_enter_guest() - kvm_make_request() however does _not_ order the write to vcpu->requests before the read of vcpu->mode, even though it's needed. Usually that's handled by kvm_vcpu_exiting_guest_mode(), but in this case vcpu->mode is read in kvm_vcpu_trigger_posted_interrupt. So vmx_deliver_nested_posted_interrupt() is missing a smp_mb__after_atomic(). It's documentation only for x86, but still easily done in v3. Paolo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel