All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Xu <anthony.xu@intel.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, eblake@redhat.com,
	Anthony Xu <anthony.xu@intel.com>
Subject: [Qemu-devel] [PATCH 2/4] pam: Make PAM configurable
Date: Fri,  7 Apr 2017 17:45:34 -0700	[thread overview]
Message-ID: <1491612336-31066-3-git-send-email-anthony.xu@intel.com> (raw)
In-Reply-To: <1491612336-31066-1-git-send-email-anthony.xu@intel.com>

by default PAM is enabled. when PAM is disabled,
*_init_pam and *_update_pam are dummy functions

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
---
 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 value, Error **errp)
     pcms->pit = value;
 }
 
+static bool pc_machine_get_pam(Object *obj, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    return pcms->pam;
+}
+
+static void pc_machine_set_pam(Object *obj, bool value, Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+
+    pcms->pam = value;
+}
+
 static void pc_machine_initfn(Object *obj)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
@@ -2224,6 +2238,7 @@ static void pc_machine_initfn(Object *obj)
     pcms->smbus = true;
     pcms->sata = true;
     pcms->pit = true;
+    pcms->pam = true;
 }
 
 static void pc_machine_reset(void)
@@ -2372,6 +2387,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
 
     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);
 }
 
 static const TypeInfo pc_machine_info = {
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)
 
 static void i440fx_update_pam(PCII440FXState *d)
 {
-    int i;
-    PCIDevice *pd = PCI_DEVICE(d);
-    memory_region_transaction_begin();
-    pam_update(&d->pam_regions[0], 0,
-               pd->config[I440FX_PAM]);
-    for (i = 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 = PCI_DEVICE(d);
+        memory_region_transaction_begin();
+        pam_update(&d->pam_regions[0], 0,
+                   pd->config[I440FX_PAM]);
+        for (i = 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();
 }
 
 static void i440fx_update_memory_mappings(PCII440FXState *d)
@@ -173,14 +175,16 @@ static void i440fx_update_memory_mappings(PCII440FXState *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 = 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 = 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);
+        }
     }
 }
 
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 = PCI_DEVICE(mch);
-    int i;
-
-    memory_region_transaction_begin();
-    for (i = 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 = PCI_DEVICE(mch);
+        int i;
+
+        memory_region_transaction_begin();
+        for (i = 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();
 }
 
 /* SMRAM */
@@ -462,14 +464,16 @@ static void mch_reset(DeviceState *qdev)
 
 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 = 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 = 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);
+        }
     }
 }
 
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;
 
     /* 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"
 
 /**
  * PCMachineClass:
-- 
1.8.3.1

  parent reply	other threads:[~2017-04-08  0:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-08  0:45 [Qemu-devel] [PATCH 0/4] pam: make pam configurable Anthony Xu
2017-04-08  0:45 ` [Qemu-devel] [PATCH 1/4] pam:refactor PAM related code Anthony Xu
2017-04-08  9:49   ` Paolo Bonzini
2017-04-11  1:25     ` Xu, Anthony
2017-04-08  0:45 ` Anthony Xu [this message]
2017-04-08  0:45 ` [Qemu-devel] [PATCH 3/4] pam: disable pc.rom when pam is disabled Anthony Xu
2017-04-08  0:45 ` [Qemu-devel] [PATCH 4/4] pam: setup pc.bios Anthony Xu
2017-04-08  9:49   ` Paolo Bonzini
2017-04-11  1:42     ` Xu, Anthony
2017-04-11  9:18       ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491612336-31066-3-git-send-email-anthony.xu@intel.com \
    --to=anthony.xu@intel.com \
    --cc=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.