Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3289598pxk; Mon, 21 Sep 2020 09:48:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzu482CjSdPrEPn19gPlUjIpbXInd8TLfiFnHp7OaIJl1cozyL5kEz3U7DTuMaS7YzaU/Z3 X-Received: by 2002:a05:6402:cba:: with SMTP id cn26mr573289edb.230.1600706891158; Mon, 21 Sep 2020 09:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706891; cv=none; d=google.com; s=arc-20160816; b=tMRVLVAZhxvAExxPXgpr2xYDcdKkp46XPQWf3sJTFM3BcPn6LsEJhNq2jNrP07I+Hr 3qI+tg5pmnxdrMcLnpDIEP2RW3RQfaKVDbVpZp7Mref69r58KD2x1D+oXu4jgKAfMCOS ump+j0OpwcYJWcqIwqG+0Uwe03ENqyt4Nqr6JwO7QHJylsT0VFBvgsjAKJiaxgH6GrZi L4DDIt541tYID8CYpfgGsCGL+JvtPR7gGYnxZH39ieaKqmZ4s6w8PNbd8dp2iRSqnPSt uuWqrsA/03Gwb8CkSvVInw7RcQLocDkdl6N9ojCn2IimDdLvvpPCK6iDgXZMRtRGc38G lgjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dxG7E0HBFjG48Rwppkbr0E4GoH9pcghQhLpKXBkTpQg=; b=c8IN8f5b6CFjYQSduQshFNjVMSIq+XMhmxqnNVfrXdE5HIy+pxviJ5y1hIZ1wQkhu5 HdGgFVWQlcm+hUAdh2myITVU75lohbYTWrOS3A9QXngkejZU3cJ8QZH+yUhftMsLLj90 KjyOdHrmVQRsH0UIt99OO4xDzdLUk4VrU3QrK9GDJztUWSR89gbuiF+CqWxGRBxeHfse 0ry5DvaXa7WNkiXL/3gPvojoke1pOAO4xKvwu+U3eYKgvQjLptg+MR1x8AWZ6fZH/5FM 6bGARG1fDf9HoOsaPtZgJQWcSBN6amZkPGSeOdWqxRPlyNOkduG0XRaJ9Q+xw6vme2wh Zsjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mY7rvqqg; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rn4si10039325ejb.143.2020.09.21.09.47.47; Mon, 21 Sep 2020 09:48:11 -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=@kernel.org header.s=default header.b=mY7rvqqg; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729440AbgIUQpr (ORCPT + 99 others); Mon, 21 Sep 2020 12:45:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:51642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729515AbgIUQph (ORCPT ); Mon, 21 Sep 2020 12:45:37 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 687B323788; Mon, 21 Sep 2020 16:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706735; bh=9zGEvBYjjk3/TckniU3gjntHp7zocFs48AHjGEiHBsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mY7rvqqgPyGm6StdN/UD9R1IHq9InA9rhHA+sMqbHE5ZAqQCyuLzULcexYyOEmeUD y5Sz8GtOePzTwFvaGUFug3Xk0NaqtliFtqvviVJePKjCfECaZceYQGH5U5ATCHHq5x ZAtPQ8tYjyUw7LHd9FOwmzYhwjGQE9LbH4u6+mNM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Levitsky , Suravee Suthikulpanit , Joao Martins , Joerg Roedel , Sasha Levin Subject: [PATCH 5.8 074/118] iommu/amd: Restore IRTE.RemapEn bit for amd_iommu_activate_guest_mode Date: Mon, 21 Sep 2020 18:28:06 +0200 Message-Id: <20200921162039.772722555@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit [ Upstream commit e97685abd5d711c885053d4949178f7ab9acbaef ] Commit e52d58d54a32 ("iommu/amd: Use cmpxchg_double() when updating 128-bit IRTE") removed an assumption that modify_irte_ga always set the valid bit, which requires the callers to set the appropriate value for the struct irte_ga.valid bit before calling the function. Similar to the commit 26e495f34107 ("iommu/amd: Restore IRTE.RemapEn bit after programming IRTE"), which is for the function amd_iommu_deactivate_guest_mode(). The same change is also needed for the amd_iommu_activate_guest_mode(). Otherwise, this could trigger IO_PAGE_FAULT for the VFIO based VMs with AVIC enabled. Fixes: e52d58d54a321 ("iommu/amd: Use cmpxchg_double() when updating 128-bit IRTE") Reported-by: Maxim Levitsky Signed-off-by: Suravee Suthikulpanit Tested-by: Maxim Levitsky Reviewed-by: Joao Martins Reviewed-by: Maxim Levitsky Cc: Joao Martins Link: https://lore.kernel.org/r/20200916111720.43913-1-suravee.suthikulpanit@amd.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/amd/iommu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 48fe272da6e9c..a51dcf26b09f2 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3831,14 +3831,18 @@ int amd_iommu_activate_guest_mode(void *data) { struct amd_ir_data *ir_data = (struct amd_ir_data *)data; struct irte_ga *entry = (struct irte_ga *) ir_data->entry; + u64 valid; if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) || !entry || entry->lo.fields_vapic.guest_mode) return 0; + valid = entry->lo.fields_vapic.valid; + entry->lo.val = 0; entry->hi.val = 0; + entry->lo.fields_vapic.valid = valid; entry->lo.fields_vapic.guest_mode = 1; entry->lo.fields_vapic.ga_log_intr = 1; entry->hi.fields.ga_root_ptr = ir_data->ga_root_ptr; -- 2.25.1