From nobody Tue Nov 11 21:12:16 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565954723; cv=none; d=zoho.com; s=zohoarc; b=ApHozZem6yJR8Y9egNB12GEvIA6irsoxENa50RmCxSqwgJj+hHGQ6SSueYTpSesYMKpbDCJwtEBhU+MKHLf7BP+swJTFH8w6oHUPbmFpy8apLAhH13cjqQU3lUq1F29EeWjtDJE5dBzo93kmlMVmJnzGkelG2psfJuel1qOUhsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565954723; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QNRyWKQ88aYLYfj+2z/KVrmftjIDTGowlCk5szu1h+U=; b=BgyAeeNk29/+WwCLz1Xbsrz+p3JcFmy+F8543u18lMm0qRqcSA8Qg4LfYhHIqrvvCYVhXz056LQYcPG2+YG1mOHmKgzkOvALKQVaLojdkGt6LXhSLMR7friSEHTiRvPzIqwVZhONZYCsbTr1m7KWZnVDYX9BcBytJOuxqTRsGEE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565954723423879.680515413909; Fri, 16 Aug 2019 04:25:23 -0700 (PDT) Received: from localhost ([::1]:54068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyaME-0000nS-AI for importer@patchew.org; Fri, 16 Aug 2019 07:25:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47925) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyaLC-0008F8-Mq for qemu-devel@nongnu.org; Fri, 16 Aug 2019 07:24:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyaLB-0008FK-LG for qemu-devel@nongnu.org; Fri, 16 Aug 2019 07:24:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54792) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hyaLB-0008Eo-G4 for qemu-devel@nongnu.org; Fri, 16 Aug 2019 07:24:17 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBB813090FCE; Fri, 16 Aug 2019 11:24:16 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF17C43FF3; Fri, 16 Aug 2019 11:24:14 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 16 Aug 2019 07:24:06 -0400 Message-Id: <20190816112407.28180-2-imammedo@redhat.com> In-Reply-To: <20190816112407.28180-1-imammedo@redhat.com> References: <20190816112407.28180-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 16 Aug 2019 11:24:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH QEMU 1/1] q35: use dedicated SMRAM at default SMM_BASE 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: "Chen, Yingwen" , edk2-devel-groups-io , Phillip Goerl , "Yao, Jiewen" , "Nakajima, Jun" , pbonzini@redhat.com, Boris Ostrovsky , edk2-rfc-groups-io , Laszlo Ersek , Joao Marcal Lemos Martins Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" it will allow us to hide sensetive SMM_BASE area from non SMM running env, that will allow us to ensure that hotplugged CPU will run trusted SMM BASE relocation code and we won't need to force all present CPUs into SMM mode since we don not care about about 0x30000 content in normal RAM address space. it's a obviously a hack only to demo approach. for easy SMI initialization on SMI entry point SMRAM is aliased in to hajaked normal RAM address space at a0000. Patch should be used with supplied SMBIOS patch, that drops save/restore sequence and just inits SMI entry point. to test to run: qemu-system-x86_64 -M q35 -bios /path_to_seabios/out/bios.bin \ -nodefaults \ -chardev stdio,id=3Dseabios -device isa-debugcon,iobase=3D0x402,chardev= =3Dseabios Signed-off-by: Igor Mammedov --- include/hw/pci-host/q35.h | 1 + hw/pci-host/q35.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h index 5ed77facd0..556ecb835a 100644 --- a/include/hw/pci-host/q35.h +++ b/include/hw/pci-host/q35.h @@ -55,6 +55,7 @@ typedef struct MCHPCIState { MemoryRegion smram_region, open_high_smram; MemoryRegion smram, low_smram, high_smram; MemoryRegion tseg_blackhole, tseg_window; + MemoryRegion smbase, smram_alias; Range pci_hole; uint64_t below_4g_mem_size; uint64_t above_4g_mem_size; diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 0a010be4cf..6c4c0f308c 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -574,6 +574,16 @@ static void mch_realize(PCIDevice *d, Error **errp) memory_region_set_enabled(&mch->tseg_window, false); memory_region_add_subregion(&mch->smram, mch->below_4g_mem_size, &mch->tseg_window); + + memory_region_init_ram(&mch->smm_base, OBJECT(mch), "SMM BASE", MCH_HO= ST_BRIDGE_SMRAM_C_SIZE, &error_fatal); + memory_region_set_enabled(&mch->smm_base, true); + memory_region_add_subregion(&mch->smram, 0x30000, &mch->smm_base); + + memory_region_init_alias(&mch->smm_base_alias, OBJECT(mch), "smim_base= _alias", + &mch->smm_base, 0, MCH_HOST_BRIDGE_SMRAM_C_SI= ZE); + memory_region_set_enabled(&mch->smm_base_alias, true); + memory_region_add_subregion_overlap(mch->system_memory, MCH_HOST_BRIDG= E_SMRAM_C_BASE, &mch->smm_base_alias, 1); + object_property_add_const_link(qdev_get_machine(), "smram", OBJECT(&mch->smram), &error_abort); =20 --=20 2.18.1