From nobody Tue May 7 22:55:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491612088759563.5293744217989; Fri, 7 Apr 2017 17:41:28 -0700 (PDT) Received: from localhost ([::1]:53092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cweRT-0003nO-03 for importer@patchew.org; Fri, 07 Apr 2017 20:41:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwePp-0002YN-IE for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwePn-0007x6-Bc for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:45 -0400 Received: from mga14.intel.com ([192.55.52.115]:44873) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwePn-0007w8-3P for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:43 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Apr 2017 17:39:38 -0700 Received: from anthony.sc.intel.com ([10.3.52.155]) by orsmga001.jf.intel.com with ESMTP; 07 Apr 2017 17:39:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491611982; x=1523147982; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=CksHt9OKGpnbyKslXlo7003D6l63H3estQ4r2yPrWaQ=; b=GhHQt2OHek6SedurHowBEvo0iRFSjR3flDNC9KVEnwMbpcRGwbbqEjuE 56lta48A4icBEJx06gd+5BQLvP3qYw==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,168,1488873600"; d="scan'208";a="1117127720" From: Anthony Xu To: qemu-devel@nongnu.org Date: Fri, 7 Apr 2017 17:45:33 -0700 Message-Id: <1491612336-31066-2-git-send-email-anthony.xu@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1491612336-31066-1-git-send-email-anthony.xu@intel.com> References: <1491612336-31066-1-git-send-email-anthony.xu@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 1/4] pam:refactor PAM related code 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: pbonzini@redhat.com, Anthony Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" split PAM SMRAM functions in piix.c create mch_init_pam in q35.c Signed-off-by: Anthony Xu --- hw/pci-host/piix.c | 58 ++++++++++++++++++++++++++++++++++++++------------= ---- hw/pci-host/q35.c | 23 +++++++++++++--------- 2 files changed, 55 insertions(+), 26 deletions(-) diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index f9218aa..ff4e8b5 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -138,16 +138,11 @@ static int pci_slot_get_pirq(PCIDevice *pci_dev, int = pci_intx) return (pci_intx + slot_addend) & 3; } =20 -static void i440fx_update_memory_mappings(PCII440FXState *d) +static void i440fx_update_smram(PCII440FXState *d) { - int i; PCIDevice *pd =3D PCI_DEVICE(d); =20 memory_region_transaction_begin(); - for (i =3D 0; i < 13; i++) { - pam_update(&d->pam_regions[i], i, - pd->config[I440FX_PAM + ((i + 1) / 2)]); - } memory_region_set_enabled(&d->smram_region, !(pd->config[I440FX_SMRAM] & SMRAM_D_OPEN)); memory_region_set_enabled(&d->smram, @@ -155,6 +150,39 @@ static void i440fx_update_memory_mappings(PCII440FXSta= te *d) memory_region_transaction_commit(); } =20 +static void i440fx_update_pam(PCII440FXState *d) +{ + int i; + PCIDevice *pd =3D PCI_DEVICE(d); + memory_region_transaction_begin(); + pam_update(&d->pam_regions[0], 0, + pd->config[I440FX_PAM]); + for (i =3D 1; i < 13; i++) { + pam_update(&d->pam_regions[i], i, + pd->config[I440FX_PAM + ((i + 1) / 2)]); + } + memory_region_transaction_commit(); +} + +static void i440fx_update_memory_mappings(PCII440FXState *d) +{ + i440fx_update_pam(d); + i440fx_update_smram(d); +} + + +static void i440fx_init_pam(PCII440FXState *d) +{ + int i; + init_pam(DEVICE(d), d->ram_memory, d->system_memory, + d->pci_address_space, &d->pam_regions[0], + PAM_BIOS_BASE, PAM_BIOS_SIZE); + for (i =3D 0; i < 12; ++i) { + init_pam(DEVICE(d), d->ram_memory, d->system_memory, + d->pci_address_space, &d->pam_regions[i + 1], + PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); + } +} =20 static void i440fx_write_config(PCIDevice *dev, uint32_t address, uint32_t val, int len) @@ -163,9 +191,12 @@ static void i440fx_write_config(PCIDevice *dev, =20 /* XXX: implement SMRAM.D_LOCK */ pci_default_write_config(dev, address, val, len); - if (ranges_overlap(address, len, I440FX_PAM, I440FX_PAM_SIZE) || - range_covers_byte(address, len, I440FX_SMRAM)) { - i440fx_update_memory_mappings(d); + if (ranges_overlap(address, len, I440FX_PAM, I440FX_PAM_SIZE)) { + i440fx_update_pam(d); + } + + if (range_covers_byte(address, len, I440FX_SMRAM)) { + i440fx_update_smram(d); } } =20 @@ -335,7 +366,6 @@ PCIBus *i440fx_init(const char *host_type, const char *= pci_type, PCIHostState *s; PIIX3State *piix3; PCII440FXState *f; - unsigned i; I440FXState *i440fx; =20 dev =3D qdev_create(NULL, host_type); @@ -378,13 +408,7 @@ PCIBus *i440fx_init(const char *host_type, const char = *pci_type, object_property_add_const_link(qdev_get_machine(), "smram", OBJECT(&f->smram), &error_abort); =20 - init_pam(dev, f->ram_memory, f->system_memory, f->pci_address_space, - &f->pam_regions[0], PAM_BIOS_BASE, PAM_BIOS_SIZE); - for (i =3D 0; i < 12; ++i) { - init_pam(dev, f->ram_memory, f->system_memory, f->pci_address_spac= e, - &f->pam_regions[i+1], PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, - PAM_EXPAN_SIZE); - } + i440fx_init_pam(f); =20 /* Xen supports additional interrupt routes from the PCI devices to * the IOAPIC: the four pins of each PCI device on the bus are also diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 344f77b..8866357 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -460,9 +460,21 @@ static void mch_reset(DeviceState *qdev) mch_update(mch); } =20 -static void mch_realize(PCIDevice *d, Error **errp) +static void mch_init_pam(MCHPCIState *mch) { int i; + init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, + mch->pci_address_space, &mch->pam_regions[0], + PAM_BIOS_BASE, PAM_BIOS_SIZE); + for (i =3D 0; i < 12; ++i) { + init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, + mch->pci_address_space, &mch->pam_regions[i + 1], + PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); + } +} + +static void mch_realize(PCIDevice *d, Error **errp) +{ MCHPCIState *mch =3D MCH_PCI_DEVICE(d); =20 /* setup pci memory mapping */ @@ -510,14 +522,7 @@ static void mch_realize(PCIDevice *d, Error **errp) object_property_add_const_link(qdev_get_machine(), "smram", OBJECT(&mch->smram), &error_abort); =20 - init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, - mch->pci_address_space, &mch->pam_regions[0], - PAM_BIOS_BASE, PAM_BIOS_SIZE); - for (i =3D 0; i < 12; ++i) { - init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, - mch->pci_address_space, &mch->pam_regions[i+1], - PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); - } + mch_init_pam(mch); } =20 uint64_t mch_mcfg_base(void) --=20 1.8.3.1 From nobody Tue May 7 22:55:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491612089090872.0261839870959; Fri, 7 Apr 2017 17:41:29 -0700 (PDT) Received: from localhost ([::1]:53093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cweRT-0003ni-NP for importer@patchew.org; Fri, 07 Apr 2017 20:41:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwePp-0002YM-I5 for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwePn-0007xG-My for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:45 -0400 Received: from mga14.intel.com ([192.55.52.115]:37867) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwePn-0007wz-B6 for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:43 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Apr 2017 17:39:38 -0700 Received: from anthony.sc.intel.com ([10.3.52.155]) by orsmga001.jf.intel.com with ESMTP; 07 Apr 2017 17:39:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491611983; x=1523147983; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=aUzTAZzJEdBxl+qH3wksmqq1Kq2N4gSMgEmjIEXaTkY=; b=ok5AVnakNAi+VE1/ltHcYheTpgwtjR+s+hiNN2IGt6v2SNfSeOR4rQs+ e/YHOqQOyIRah4ss4MrPh6ZaG/LxBw==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,168,1488873600"; d="scan'208";a="1117127723" From: Anthony Xu To: qemu-devel@nongnu.org Date: Fri, 7 Apr 2017 17:45:34 -0700 Message-Id: <1491612336-31066-3-git-send-email-anthony.xu@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1491612336-31066-1-git-send-email-anthony.xu@intel.com> References: <1491612336-31066-1-git-send-email-anthony.xu@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 2/4] pam: Make PAM configurable 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: pbonzini@redhat.com, Anthony Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" by default PAM is enabled. when PAM is disabled, *_init_pam and *_update_pam are dummy functions Signed-off-by: Anthony Xu --- hw/i386/pc.c | 18 ++++++++++++++++++ hw/pci-host/piix.c | 36 ++++++++++++++++++++---------------- hw/pci-host/q35.c | 34 +++++++++++++++++++--------------- include/hw/i386/pc.h | 2 ++ 4 files changed, 59 insertions(+), 31 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index d24388e..9d154c2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2210,6 +2210,20 @@ static void pc_machine_set_pit(Object *obj, bool val= ue, Error **errp) pcms->pit =3D value; } =20 +static bool pc_machine_get_pam(Object *obj, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + return pcms->pam; +} + +static void pc_machine_set_pam(Object *obj, bool value, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + pcms->pam =3D value; +} + static void pc_machine_initfn(Object *obj) { PCMachineState *pcms =3D PC_MACHINE(obj); @@ -2224,6 +2238,7 @@ static void pc_machine_initfn(Object *obj) pcms->smbus =3D true; pcms->sata =3D true; pcms->pit =3D true; + pcms->pam =3D true; } =20 static void pc_machine_reset(void) @@ -2372,6 +2387,9 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) =20 object_class_property_add_bool(oc, PC_MACHINE_PIT, pc_machine_get_pit, pc_machine_set_pit, &error_abort); + + object_class_property_add_bool(oc, PC_MACHINE_PAM, + pc_machine_get_pam, pc_machine_set_pam, &error_abort); } =20 static const TypeInfo pc_machine_info =3D { diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index ff4e8b5..7497516 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -152,16 +152,18 @@ static void i440fx_update_smram(PCII440FXState *d) =20 static void i440fx_update_pam(PCII440FXState *d) { - int i; - PCIDevice *pd =3D PCI_DEVICE(d); - memory_region_transaction_begin(); - pam_update(&d->pam_regions[0], 0, - pd->config[I440FX_PAM]); - for (i =3D 1; i < 13; i++) { - pam_update(&d->pam_regions[i], i, - pd->config[I440FX_PAM + ((i + 1) / 2)]); + if (PC_MACHINE(current_machine)->pam) { + int i; + PCIDevice *pd =3D PCI_DEVICE(d); + memory_region_transaction_begin(); + pam_update(&d->pam_regions[0], 0, + pd->config[I440FX_PAM]); + for (i =3D 1; i < 13; i++) { + pam_update(&d->pam_regions[i], i, + pd->config[I440FX_PAM + ((i + 1) / 2)]); + } + memory_region_transaction_commit(); } - memory_region_transaction_commit(); } =20 static void i440fx_update_memory_mappings(PCII440FXState *d) @@ -173,14 +175,16 @@ static void i440fx_update_memory_mappings(PCII440FXSt= ate *d) =20 static void i440fx_init_pam(PCII440FXState *d) { - int i; - init_pam(DEVICE(d), d->ram_memory, d->system_memory, - d->pci_address_space, &d->pam_regions[0], - PAM_BIOS_BASE, PAM_BIOS_SIZE); - for (i =3D 0; i < 12; ++i) { + if (PC_MACHINE(current_machine)->pam) { + int i; init_pam(DEVICE(d), d->ram_memory, d->system_memory, - d->pci_address_space, &d->pam_regions[i + 1], - PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); + d->pci_address_space, &d->pam_regions[0], + PAM_BIOS_BASE, PAM_BIOS_SIZE); + for (i =3D 0; i < 12; ++i) { + init_pam(DEVICE(d), d->ram_memory, d->system_memory, + d->pci_address_space, &d->pam_regions[i + 1], + PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); + } } } =20 diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 8866357..e63b057 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -310,15 +310,17 @@ static void mch_update_pciexbar(MCHPCIState *mch) /* PAM */ static void mch_update_pam(MCHPCIState *mch) { - PCIDevice *pd =3D PCI_DEVICE(mch); - int i; - - memory_region_transaction_begin(); - for (i =3D 0; i < 13; i++) { - pam_update(&mch->pam_regions[i], i, - pd->config[MCH_HOST_BRIDGE_PAM0 + ((i + 1) / 2)]); + if (PC_MACHINE(current_machine)->pam) { + PCIDevice *pd =3D PCI_DEVICE(mch); + int i; + + memory_region_transaction_begin(); + for (i =3D 0; i < 13; i++) { + pam_update(&mch->pam_regions[i], i, + pd->config[MCH_HOST_BRIDGE_PAM0 + ((i + 1) / 2)]); + } + memory_region_transaction_commit(); } - memory_region_transaction_commit(); } =20 /* SMRAM */ @@ -462,14 +464,16 @@ static void mch_reset(DeviceState *qdev) =20 static void mch_init_pam(MCHPCIState *mch) { - int i; - init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, - mch->pci_address_space, &mch->pam_regions[0], - PAM_BIOS_BASE, PAM_BIOS_SIZE); - for (i =3D 0; i < 12; ++i) { + if (PC_MACHINE(current_machine)->pam) { + int i; init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, - mch->pci_address_space, &mch->pam_regions[i + 1], - PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); + mch->pci_address_space, &mch->pam_regions[0], + PAM_BIOS_BASE, PAM_BIOS_SIZE); + for (i =3D 0; i < 12; ++i) { + init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, + mch->pci_address_space, &mch->pam_regions[i + 1], + PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); + } } } =20 diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f278b3a..05f4df5 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -66,6 +66,7 @@ struct PCMachineState { bool smbus; bool sata; bool pit; + bool pam; =20 /* RAM information (sizes, addresses, configuration): */ ram_addr_t below_4g_mem_size, above_4g_mem_size; @@ -93,6 +94,7 @@ struct PCMachineState { #define PC_MACHINE_SMBUS "smbus" #define PC_MACHINE_SATA "sata" #define PC_MACHINE_PIT "pit" +#define PC_MACHINE_PAM "pam" =20 /** * PCMachineClass: --=20 1.8.3.1 From nobody Tue May 7 22:55:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491612177138640.1078042538861; Fri, 7 Apr 2017 17:42:57 -0700 (PDT) Received: from localhost ([::1]:53097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cweSt-00057b-5j for importer@patchew.org; Fri, 07 Apr 2017 20:42:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwePp-0002YL-Hm for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwePn-0007xO-QI for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:45 -0400 Received: from mga14.intel.com ([192.55.52.115]:44873) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwePn-0007w8-HP for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:43 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Apr 2017 17:39:38 -0700 Received: from anthony.sc.intel.com ([10.3.52.155]) by orsmga001.jf.intel.com with ESMTP; 07 Apr 2017 17:39:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491611983; x=1523147983; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=HgVGMOKFOd0/P76g8CbGJfazF8CYqUl5EmlWASQBeOQ=; b=hdgqEBRmdbDPIFurqy2eB3UKdHnafAbUMbBVkuE2QEstztJaHKTbaWxS X3dg2MmU+aSdid/yDPEY+ep7HZA4pw==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,168,1488873600"; d="scan'208";a="1117127726" From: Anthony Xu To: qemu-devel@nongnu.org Date: Fri, 7 Apr 2017 17:45:35 -0700 Message-Id: <1491612336-31066-4-git-send-email-anthony.xu@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1491612336-31066-1-git-send-email-anthony.xu@intel.com> References: <1491612336-31066-1-git-send-email-anthony.xu@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 3/4] pam: disable pc.rom when pam is disabled 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: pbonzini@redhat.com, Anthony Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" pc.rom depends on pam. When pam is disabled, pc.rom is useless Signed-off-by: Anthony Xu --- hw/i386/pc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 9d154c2..455f7fe 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1358,7 +1358,7 @@ void pc_memory_init(PCMachineState *pcms, MemoryRegion **ram_memory) { int linux_boot, i; - MemoryRegion *ram, *option_rom_mr; + MemoryRegion *ram; MemoryRegion *ram_below_4g, *ram_above_4g; FWCfgState *fw_cfg; MachineState *machine =3D MACHINE(pcms); @@ -1445,15 +1445,16 @@ void pc_memory_init(PCMachineState *pcms, /* Initialize PC system firmware */ pc_system_firmware_init(rom_memory, !pcmc->pci_enabled); =20 - option_rom_mr =3D g_malloc(sizeof(*option_rom_mr)); - memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE, + if (pcms->pam) { + MemoryRegion *option_rom_mr =3D g_malloc(sizeof(*option_rom_mr)); + memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE, &error_fatal); - vmstate_register_ram_global(option_rom_mr); - memory_region_add_subregion_overlap(rom_memory, + vmstate_register_ram_global(option_rom_mr); + memory_region_add_subregion_overlap(rom_memory, PC_ROM_MIN_VGA, option_rom_mr, 1); - + } fw_cfg =3D bochs_bios_init(&address_space_memory, pcms); =20 rom_set_fw(fw_cfg); --=20 1.8.3.1 From nobody Tue May 7 22:55:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491612088758696.9314098799939; Fri, 7 Apr 2017 17:41:28 -0700 (PDT) Received: from localhost ([::1]:53091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cweRS-0003mE-3q for importer@patchew.org; Fri, 07 Apr 2017 20:41:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwePp-0002YQ-K1 for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwePo-0007xZ-6D for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:45 -0400 Received: from mga14.intel.com ([192.55.52.115]:37867) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwePn-0007wz-Sf for qemu-devel@nongnu.org; Fri, 07 Apr 2017 20:39:44 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Apr 2017 17:39:38 -0700 Received: from anthony.sc.intel.com ([10.3.52.155]) by orsmga001.jf.intel.com with ESMTP; 07 Apr 2017 17:39:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491611983; x=1523147983; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=+DSA+selbkYPW32pZTyt2AXEgOsUKzwdLEeOakoaLuE=; b=NnP7KSL4gd0vkAT8RGFRgRuO5LIYjdChAAnRxmO7PAaIM9vBTRVBNrqj ULcIL0+wbCktytR+isEy0hr0wmrmUQ==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,168,1488873600"; d="scan'208";a="1117127729" From: Anthony Xu To: qemu-devel@nongnu.org Date: Fri, 7 Apr 2017 17:45:36 -0700 Message-Id: <1491612336-31066-5-git-send-email-anthony.xu@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1491612336-31066-1-git-send-email-anthony.xu@intel.com> References: <1491612336-31066-1-git-send-email-anthony.xu@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH 4/4] pam: setup pc.bios 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: pbonzini@redhat.com, Anthony Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" when pam is disabled, set pc.bios and isa.bios region as writeable, and add isa.bios to system memory region. Signed-off-by: Anthony Xu --- hw/i386/pc.c | 2 +- hw/i386/pc_sysfw.c | 30 +++++++++++++++++++++--------- include/hw/i386/pc.h | 4 +++- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 455f7fe..3e23f58 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1443,7 +1443,7 @@ void pc_memory_init(PCMachineState *pcms, } =20 /* Initialize PC system firmware */ - pc_system_firmware_init(rom_memory, !pcmc->pci_enabled); + pc_system_firmware_init(system_memory, rom_memory, !pcmc->pci_enabled); =20 if (pcms->pam) { MemoryRegion *option_rom_mr =3D g_malloc(sizeof(*option_rom_mr)); diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index f915ad0..e5ac615 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -173,7 +173,8 @@ static void pc_system_flash_init(MemoryRegion *rom_memo= ry) } } =20 -static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ra= m_fw) +static void old_pc_system_rom_init(MemoryRegion *system_memory, + MemoryRegion *rom_memory, bool isapc_ra= m_fw) { char *filename; MemoryRegion *bios, *isa_bios; @@ -197,8 +198,11 @@ static void old_pc_system_rom_init(MemoryRegion *rom_m= emory, bool isapc_ram_fw) bios =3D g_malloc(sizeof(*bios)); memory_region_init_ram(bios, NULL, "pc.bios", bios_size, &error_fatal); vmstate_register_ram_global(bios); - if (!isapc_ram_fw) { - memory_region_set_readonly(bios, true); + if (PC_MACHINE(current_machine)->pam) { + /* if PAM is disabled, set it as readwrite */ + if (!isapc_ram_fw) { + memory_region_set_readonly(bios, true); + } } ret =3D rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); if (ret !=3D 0) { @@ -216,21 +220,29 @@ static void old_pc_system_rom_init(MemoryRegion *rom_= memory, bool isapc_ram_fw) isa_bios =3D g_malloc(sizeof(*isa_bios)); memory_region_init_alias(isa_bios, NULL, "isa-bios", bios, bios_size - isa_bios_size, isa_bios_size); - memory_region_add_subregion_overlap(rom_memory, + if (PC_MACHINE(current_machine)->pam) { + memory_region_add_subregion_overlap(rom_memory, + 0x100000 - isa_bios_size, + isa_bios, + 1); + if (!isapc_ram_fw) { + memory_region_set_readonly(isa_bios, true); + } + } else { + /* if PAM is disabed, add isa-bios to system memory region */ + memory_region_add_subregion_overlap(system_memory, 0x100000 - isa_bios_size, isa_bios, 1); - if (!isapc_ram_fw) { - memory_region_set_readonly(isa_bios, true); } - /* map all the bios at the top of memory */ memory_region_add_subregion(rom_memory, (uint32_t)(-bios_size), bios); } =20 -void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw) +void pc_system_firmware_init(MemoryRegion *system_memory, + MemoryRegion *rom_memory, bool isapc_ram_fw) { DriveInfo *pflash_drv; =20 @@ -238,7 +250,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory, = bool isapc_ram_fw) =20 if (isapc_ram_fw || pflash_drv =3D=3D NULL) { /* When a pflash drive is not found, use rom-mode */ - old_pc_system_rom_init(rom_memory, isapc_ram_fw); + old_pc_system_rom_init(system_memory, rom_memory, isapc_ram_fw); return; } =20 diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 05f4df5..eb5b853 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -354,7 +354,9 @@ static inline bool isa_ne2000_init(ISABus *bus, int bas= e, int irq, NICInfo *nd) } =20 /* pc_sysfw.c */ -void pc_system_firmware_init(MemoryRegion *rom_memory, + +void pc_system_firmware_init(MemoryRegion *system_memory, + MemoryRegion *rom_memory, bool isapc_ram_fw); =20 /* pvpanic.c */ --=20 1.8.3.1