From patchwork Fri Sep 21 14:25:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10610167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22027112B for ; Fri, 21 Sep 2018 14:27:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FADD2DFA4 for ; Fri, 21 Sep 2018 14:27:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 037812DFE7; Fri, 21 Sep 2018 14:27:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D55482DFA4 for ; Fri, 21 Sep 2018 14:27:11 +0000 (UTC) Received: from localhost ([::1]:55908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3MOl-0002iL-4X for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 10:27:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3MNL-0001be-L0 for qemu-devel@nongnu.org; Fri, 21 Sep 2018 10:25:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3MNH-0001EN-Fk for qemu-devel@nongnu.org; Fri, 21 Sep 2018 10:25:43 -0400 Received: from mail-sn1nam01on0040.outbound.protection.outlook.com ([104.47.32.40]:62432 helo=NAM01-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3MNH-0001DT-9B for qemu-devel@nongnu.org; Fri, 21 Sep 2018 10:25:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TEhP8MDwy2m+fYfiRiAwsopC2SVkJUf3wlFL2nBBY0g=; b=hTSvKa2NhfXdH3ZNLLxGX4++EUyyXlxhSq5dzlWtbss6nN8mFSiyDCEnZsGndtgmQ4/+c0PqI63LcuWHMXhZMNNlAMOnwXHVguSiDdO+pNAmdvUUGICfmsfO0N4rU2vy93awHFQfhsdhMXjDNHIgJctqEx5WnK8R1MRgbdmBrYw= Received: from DM6PR12MB2682.namprd12.prod.outlook.com (20.176.116.31) by DM6PR12MB2617.namprd12.prod.outlook.com (20.176.116.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.19; Fri, 21 Sep 2018 14:25:37 +0000 Received: from DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::7c34:f2e8:a8a9:cab8]) by DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::7c34:f2e8:a8a9:cab8%2]) with mapi id 15.20.1143.017; Fri, 21 Sep 2018 14:25:37 +0000 From: "Singh, Brijesh" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH v3 3/9] x86_iommu/amd: remove V=1 check from amdvi_validate_dte() Thread-Index: AQHUUbb3QFs9yLNFwUuGcH4u0Ua41w== Date: Fri, 21 Sep 2018 14:25:37 +0000 Message-ID: <1537539920-30662-4-git-send-email-brijesh.singh@amd.com> References: <1537539920-30662-1-git-send-email-brijesh.singh@amd.com> In-Reply-To: <1537539920-30662-1-git-send-email-brijesh.singh@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: DM5PR21CA0008.namprd21.prod.outlook.com (2603:10b6:3:ac::18) To DM6PR12MB2682.namprd12.prod.outlook.com (2603:10b6:5:4a::31) authentication-results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM6PR12MB2617; 20:gCrRcobM8ZYjYWHZxZf6AHie7AuMKxBOHdT/LsCQfqxDwxtZwvfolcFPVr6aYEMS7o7vO7dJ3eDcUIUot1j1BfII3WdragUhG+Bt0npnYbF5HgOzgWNjHeJeZSO9rivY9xs4jX2qu9I2iNqtCRHTEh4S1wICUEiIOh8TT23iEm9d+xxeNU6KWL2qLSW+HnBdB9IhJOWsNqegOnZBC0M6ognth6w7s2EvhKLqGDyazjNhT6mybH009iy6zTquT9Ui x-ms-office365-filtering-correlation-id: 5f3b4a52-48ce-43f7-d522-08d61fce1953 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2617; x-ms-traffictypediagnostic: DM6PR12MB2617: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(163750095850)(767451399110)(85827821059158); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:DM6PR12MB2617; BCL:0; PCL:0; RULEID:; SRVR:DM6PR12MB2617; x-forefront-prvs: 0802ADD973 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(136003)(376002)(366004)(346002)(396003)(189003)(199004)(102836004)(8936002)(81156014)(81166006)(2616005)(11346002)(5640700003)(7736002)(6512007)(2351001)(446003)(486006)(6116002)(305945005)(476003)(4326008)(105586002)(106356001)(14454004)(6486002)(68736007)(3846002)(66066001)(6436002)(53936002)(25786009)(39060400002)(2906002)(256004)(14444005)(5660300001)(6916009)(86362001)(26005)(8676002)(97736004)(54906003)(76176011)(316002)(6506007)(386003)(52116002)(99286004)(2501003)(5250100002)(2900100001)(36756003)(71190400001)(71200400001)(186003)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2617; H:DM6PR12MB2682.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: JF4VPlXYXd62PgcZol8EwHPQGV+4RoDzZSJ0yCRELdtLHv8uBelClDHEbjOGRXWc5ikwBDYp3Jbuu5afVmgsI1CDF8lc7pek/nNJex59qXqxM0gvh0Z2xpuRpz1zuBgFWpca6FHdOostG/L/pGpD0W6Q636Wu93ZAhu6Ndr22jl6tuAY/4rivBk0HFJFrFbqNQGZvWDsMZptRAHffwqHM6oisUIoxXyL/cfxTlCK18U2iO+67II0wFS842xX99uEQPn/2VNevJA6zgC1hVApHPTyO6tQla2cPWKsFyVUf0tttBPifyROoEY0FwZ4ra9HVV958T7Hzm9dN2pdsNkRGMOSZ52GtmNi7lUQC0dm3W8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f3b4a52-48ce-43f7-d522-08d61fce1953 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Sep 2018 14:25:37.2527 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2617 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.32.40 Subject: [Qemu-devel] [PATCH v3 3/9] x86_iommu/amd: remove V=1 check from amdvi_validate_dte() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Lendacky, Thomas" , "Singh, Brijesh" , Eduardo Habkost , "Michael S. Tsirkin" , Peter Xu , Paolo Bonzini , "Suthikulpanit, Suravee" , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, the amdvi_validate_dte() assumes that a valid DTE will always have V=1. This is not true. The V=1 means that bit[127:1] are valid. A valid DTE can have IV=1 and V=0 (i.e address translation disabled and interrupt remapping enabled) Remove the V=1 check from amdvi_validate_dte(), make the caller responsible to check for V or IV bits. Signed-off-by: Brijesh Singh Cc: Peter Xu Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcel Apfelbaum Cc: Tom Lendacky Cc: Suravee Suthikulpanit --- hw/i386/amd_iommu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 1fd669f..f9aae02 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -807,7 +807,7 @@ static inline uint64_t amdvi_get_perms(uint64_t entry) AMDVI_DEV_PERM_SHIFT; } -/* a valid entry should have V = 1 and reserved bits honoured */ +/* validate that reserved bits are honoured */ static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, uint64_t *dte) { @@ -820,7 +820,7 @@ static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, return false; } - return dte[0] & AMDVI_DEV_VALID; + return true; } /* get a device table entry given the devid */ @@ -967,7 +967,8 @@ static void amdvi_do_translate(AMDVIAddressSpace *as, hwaddr addr, } /* devices with V = 0 are not translated */ - if (!amdvi_get_dte(s, devid, entry)) { + if (!amdvi_get_dte(s, devid, entry) || + !(entry[0] & AMDVI_DEV_VALID)) { goto out; }