From patchwork Mon Mar 30 03:25:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hang.yuan@linux.intel.com X-Patchwork-Id: 11464507 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A51792C for ; Mon, 30 Mar 2020 03:40:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 AEF3C206F5 for ; Mon, 30 Mar 2020 03:40:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AEF3C206F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:44302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIlI4-000204-Cp for patchwork-qemu-devel@patchwork.kernel.org; Sun, 29 Mar 2020 23:40:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34094) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIlHT-0001TL-Uv for qemu-devel@nongnu.org; Sun, 29 Mar 2020 23:40:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIlHS-00013H-PD for qemu-devel@nongnu.org; Sun, 29 Mar 2020 23:40:07 -0400 Received: from mga14.intel.com ([192.55.52.115]:11513) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jIlHS-0000sk-H8 for qemu-devel@nongnu.org; Sun, 29 Mar 2020 23:40:06 -0400 IronPort-SDR: qc6dRp1adZfnuebJnABJfqCeh+R3sALNhvRq3taRA/zl2RX8gvsO08STA4uJNIwiEx/JXIx/F6 02MFjF/wGWug== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2020 20:39:59 -0700 IronPort-SDR: 2LAbvnvssxk4/RJj6at/TcDVabGK17UcRQ3G3s4o2R7weEr41sPQTseM0xgVFWtiH5VcYa46yk 3otpru2UjC8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,322,1580803200"; d="scan'208";a="359053114" Received: from henry-optiplex-7050.bj.intel.com ([10.238.157.69]) by fmsmga001.fm.intel.com with ESMTP; 29 Mar 2020 20:39:58 -0700 From: hang.yuan@linux.intel.com To: qemu-devel@nongnu.org Subject: [PATCH v2] [Qemu-devel] target/i386: HAX: Enable ROM/ROM device memory region support Date: Mon, 30 Mar 2020 11:25:12 +0800 Message-Id: <1585538712-28300-1-git-send-email-hang.yuan@linux.intel.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 192.55.52.115 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hang Yuan , colin.xu@intel.com, wenchao.wang@intel.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Hang Yuan Add ROM and ROM device memory region support in HAX. Their memory region is read only and write access will generate EPT violation. The violation will be handled in the HAX kernel with the following patch. https://github.com/intel/haxm/commit/33ceea09a1655fca12c47f1e112b1d269357ff28 v2: fix coding style problems Signed-off-by: Hang Yuan Reviewed-by: Colin Xu --- target/i386/hax-mem.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/target/i386/hax-mem.c b/target/i386/hax-mem.c index 6bb5a24917..a8bfd37977 100644 --- a/target/i386/hax-mem.c +++ b/target/i386/hax-mem.c @@ -175,13 +175,10 @@ static void hax_process_section(MemoryRegionSection *section, uint8_t flags) uint64_t host_va; uint32_t max_mapping_size; - /* We only care about RAM and ROM regions */ - if (!memory_region_is_ram(mr)) { - if (memory_region_is_romd(mr)) { - /* HAXM kernel module does not support ROMD yet */ - warn_report("Ignoring ROMD region 0x%016" PRIx64 "->0x%016" PRIx64, - start_pa, start_pa + size); - } + /* We only care about RAM/ROM regions and ROM device */ + if (memory_region_is_rom(mr) || (memory_region_is_romd(mr))) { + flags |= HAX_RAM_INFO_ROM; + } else if (!memory_region_is_ram(mr)) { return; }