From patchwork Thu Jan 17 21:53:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10769183 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 0D82C13A4 for ; Thu, 17 Jan 2019 21:56:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F04B72AC6E for ; Thu, 17 Jan 2019 21:56:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E41B32FDEF; Thu, 17 Jan 2019 21:56:02 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 809862AC6E for ; Thu, 17 Jan 2019 21:56:02 +0000 (UTC) Received: from localhost ([127.0.0.1]:55694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkFdp-0003SU-Oi for patchwork-qemu-devel@patchwork.kernel.org; Thu, 17 Jan 2019 16:56:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkFbE-0001Rp-E8 for qemu-devel@nongnu.org; Thu, 17 Jan 2019 16:53:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkFbD-0000ZB-Ie for qemu-devel@nongnu.org; Thu, 17 Jan 2019 16:53:20 -0500 Received: from mail-eopbgr740047.outbound.protection.outlook.com ([40.107.74.47]:8750 helo=NAM01-BN3-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 1gkFbD-0000WF-Do for qemu-devel@nongnu.org; Thu, 17 Jan 2019 16:53:19 -0500 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=8AERD5UGh7bj8nkWYTWq78wAESAd+1IB+khGcq37iS8=; b=iKH1hYJ36hpkfglLA+3ELcO7pfRtlzbhSW76DMCnujwjW/qkODL2uSDmUVoB2UE4Ya9/CFOlKNhn6pT2ALpTbABZX5ZFQHsLCj4yJDootCZZbH+A9cJQOKKEKZy2Zfa9NGWlI35GeKemGJHNJEoJ5N0RJFFWhMo7gBd5CPQRqzE= Received: from DM6PR12MB2682.namprd12.prod.outlook.com (20.176.116.31) by DM6PR12MB2714.namprd12.prod.outlook.com (20.176.116.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.18; Thu, 17 Jan 2019 21:53:16 +0000 Received: from DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::10bf:617c:4515:4ad2]) by DM6PR12MB2682.namprd12.prod.outlook.com ([fe80::10bf:617c:4515:4ad2%2]) with mapi id 15.20.1516.019; Thu, 17 Jan 2019 21:53:16 +0000 From: "Singh, Brijesh" To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH 1/2] memory: Fix the memory region type assignment order Thread-Index: AQHUrq8MIcx0GA7wYUmLdIsIKUnt/g== Date: Thu, 17 Jan 2019 21:53:16 +0000 Message-ID: <20190117215300.29694-2-brijesh.singh@amd.com> References: <20190117215300.29694-1-brijesh.singh@amd.com> In-Reply-To: <20190117215300.29694-1-brijesh.singh@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN6PR05CA0026.namprd05.prod.outlook.com (2603:10b6:805:de::39) 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-mailer: git-send-email 2.17.1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM6PR12MB2714; 20:tAlkV88h5uAIEY5SD/77NbghF/9/CP+zf78gRI7ztmmInRuZP7oyO/0l3AAV+CgqtzEk4eFbbN6fKnvqAVVmIoRjk8+/ChSOqrcN0+SqOrZRzdWCM5yTaDkIEfP2xB/s+CmqyccHo92SnO/zRcubfiEGlJQHa8N+fhDQmCusmGUO+wUx0W3f7haIVbSkGkMHhTMtTd9wh/NswZCIK5eiscSpyVyIrWrZIKA4FYxP/B+ytQfWhjrYxQTjpQG3MBMy x-ms-office365-filtering-correlation-id: 6fca283e-32d0-4d95-5123-08d67cc62f52 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2714; x-ms-traffictypediagnostic: DM6PR12MB2714: x-microsoft-antispam-prvs: x-forefront-prvs: 0920602B08 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(346002)(39860400002)(396003)(376002)(366004)(199004)(189003)(2501003)(7736002)(6916009)(2351001)(4326008)(52116002)(68736007)(105586002)(106356001)(76176011)(6306002)(6486002)(6512007)(6436002)(81166006)(256004)(5640700003)(99286004)(81156014)(305945005)(8936002)(86362001)(53936002)(50226002)(8676002)(2906002)(446003)(14454004)(486006)(316002)(476003)(11346002)(6116002)(97736004)(1076003)(14444005)(2616005)(25786009)(3846002)(966005)(66066001)(102836004)(54906003)(36756003)(386003)(71200400001)(478600001)(71190400001)(186003)(6506007)(5660300001)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2714; H:DM6PR12MB2682.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: zO4nMilq2TuQkklLDDU641fWqRS936yjxvfUAM/UQ+JbJ/z3/qRB6aZ8fJwD59fIVxdvNjCC/r4qeFU55Dxo3D1w8mqgcCx2vMbQ48UhtVQ4n775j5rPRYSaLGU+Vz0jjmM9RQaczOAhY2k1LlNOMOFSHLbWnAH09BX0K4BNr8zNFqENjuNrvEMc8BxkK5P5qif8BtJNn9xhCuprwoZMrw188Ae9TkJXqrf3Ehl/YPoeO1zDxqrQbK21O6ZHzejCgVwrz3+TIIOI2klYXV107jr97EU5is7aDfTAOShWO5hXcHx/l8phagfbm7nvI5O+iuPC4xDdKCWaQaogUinTol5pyi6DEYIMBbu1cSKPLSgAlphkO+4d8HqAPqKKBt6BF7RB0moG9ZexSWdlclqEZXCVMyFjq5cs6Z039h2l8bo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6fca283e-32d0-4d95-5123-08d67cc62f52 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2019 21:53:15.5954 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2714 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.74.47 Subject: [Qemu-devel] [PATCH 1/2] memory: Fix the memory region type assignment order 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: Paolo Bonzini , "alex.williamson@redhat.com" , "Singh, Brijesh" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, a callback registered through the RAMBlock notifier is not able to get the memory region type (i.e callback is not able to use memory_region_is_ram_device function). This is because mr->ram assignment happens _after_ the memory is allocated whereas the callback is executed during allocation. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1667249 Sugegsted-by: Alex Williamson Cc: Paolo Bonzini Signed-off-by: Brijesh Singh Reviewed-by: Alex Williamson --- memory.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/memory.c b/memory.c index 61d66e4441..9ec15349dd 100644 --- a/memory.c +++ b/memory.c @@ -1652,10 +1652,17 @@ void memory_region_init_ram_device_ptr(MemoryRegion *mr, uint64_t size, void *ptr) { - memory_region_init_ram_ptr(mr, owner, name, size, ptr); + memory_region_init(mr, owner, name, size); + mr->ram = true; + mr->terminates = true; mr->ram_device = true; mr->ops = &ram_device_mem_ops; mr->opaque = mr; + mr->destructor = memory_region_destructor_ram; + mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; + /* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */ + assert(ptr != NULL); + mr->ram_block = qemu_ram_alloc_from_ptr(size, ptr, mr, &error_fatal); } void memory_region_init_alias(MemoryRegion *mr,