Skip to contentSkip to conversation

q35:Enable TSEG only when G_SMRAME and TSEG_EN both enabled

PATCH Applied Zhenzhong Duan 3 participants 4 messages Jun 15, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 q35:Enable TSEG only when G_SMRAME and TSEG_EN both enabled

According to spec:
"TSEG Enable (T_EN): Enabling of SMRAM memory for Extended SMRAM space only. When G_SMRAME = 1 and TSEG_EN = 1, the TSEG is enabled to appear in the appropriate physical address space. Note that once D_LCK is set, this bit becomes read only."

Changed to match the spec description.

---
 hw/pci-host/q35.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/pci-host/q35.c +2 -1
index ab5a47aff560..20da1213747c 100644
@@ -379,7 +379,8 @@ static void mch_update_smram(MCHPCIState *mch)
         memory_region_set_enabled(&mch->high_smram, false);
     }
 
-    if (pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_T_EN) {
+    if ((pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_T_EN) &&
+        (pd->config[MCH_HOST_BRIDGE_SMRAM] & SMRAM_G_SMRAME)) {
         switch (pd->config[MCH_HOST_BRIDGE_ESMRAMC] &
                 MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK) {
         case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_1MB:
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Zhenzhong Duan

According to spec:
"TSEG Enable (T_EN): Enabling of SMRAM memory for Extended SMRAM space only. When G_SMRAME = 1 and TSEG_EN = 1, the TSEG is enabled to appear in the appropriate physical address space. Note that once D_LCK is set, this bit becomes read only."

edk2 agrees and explicitly sets SMRAM_G_SMRAME:

//
// TSEG should be closed (see above), but unlocked, initially. Set G_SMRAME // (Global SMRAM Enable) too, as both D_LCK and T_EN depend on it. //
PciAndThenOr8 (

    DRAMC_REGISTER_Q35 (MCH_SMRAM),
    (UINT8)((~(UINT32)MCH_SMRAM_D_LCK) & 0xff),
    MCH_SMRAM_G_SMRAME
    );

Good.

hw/pci-host/q35.c static void mch_update_smram(MCHPCIState *mch) · line 383

Quoted 3 lines
hw/pci-host/q35.c +2 -1
-    if (pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_T_EN) {
+    if ((pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_T_EN) &&
+        (pd->config[MCH_HOST_BRIDGE_SMRAM] & SMRAM_G_SMRAME)) {

take care,
Gerd

#3 lore raw
In reply to Zhenzhong Duan
Quoted 18 lines · Zhenzhong Duan

According to spec:
"TSEG Enable (T_EN): Enabling of SMRAM memory for Extended SMRAM space only. When G_SMRAME = 1 and TSEG_EN = 1, the TSEG is enabled to appear in the appropriate physical address space. Note that once D_LCK is set, this bit becomes read only."

Changed to match the spec description.

---
  hw/pci-host/q35.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
hw/pci-host/q35.c +0 -0
index ab5a47aff560..20da1213747c 100644

hw/pci-host/q35.c static void mch_update_smram(MCHPCIState *mch) · line 386

Quoted 9 lines
hw/pci-host/q35.c +2 -1
@@ -379,7 +379,8 @@ static void mch_update_smram(MCHPCIState *mch)
          memory_region_set_enabled(&mch->high_smram, false);
      }
 
-    if (pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_T_EN) {
+    if ((pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_T_EN) &&
+        (pd->config[MCH_HOST_BRIDGE_SMRAM] & SMRAM_G_SMRAME)) {
          switch (pd->config[MCH_HOST_BRIDGE_ESMRAMC] &
                  MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK) {
          case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_1MB:

Queued, thanks.

paolo