Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6140876rwb; Tue, 22 Nov 2022 09:14:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7IWDSdk5b6QnGohvek5a5gSjMHu/wptdo3QmRJUBZooqAJOv8Npt85n3FeD6ldUPqpnPtS X-Received: by 2002:aa7:d9cf:0:b0:469:a1de:4656 with SMTP id v15-20020aa7d9cf000000b00469a1de4656mr9500957eds.425.1669137276806; Tue, 22 Nov 2022 09:14:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669137276; cv=none; d=google.com; s=arc-20160816; b=YEpcpMbwBk54G8GMFFkZS0ElOwD6YxNI1F5KLblfw2aSkYfN1qwpou5TMEKJNW6l8H YMYVLLizMhkH8ZhB+YU6JLMccZ908i7jY08m4qqvud6zti9tbkv1VwvnpilXwg/k9PUg 2BIUrmIptHudMECt2C5xjegN4Dd/UKMJAIFAwg5UzeL6qecNs366zxzBV6KY0bjdaYMN hwJbSucQsitS0+Vg07fdt511s89D3NVGt3HQRaX13WNApVGMvtPD+HxELCCesF3uthvS y+fp05wWE5lLmdCpU3ouKn0EybfPclul8NIVkRwez186CiMFhzMfvSftrun5prDzg9av d25A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+I+NFNsrgPcwpbYEM36avO5tqcTUKJxcOE3LZCYPOzk=; b=P1xc5CU2I3X3IsdEccKgOjDSjZ/4KvoZk/ZDsCiTXgPpPdfdaxrDLYOyUosVcndHnK vqVnk1qKiHpkbG7No/7PxwRbogBKKl2K3Y0gf9i0Qk5nwfAw54edGsOmyiC29aHDks+I r+TKGJ4TAFjTlGblv0eCorPZXmhzHYHSZKxVB3f+hCBPKcCLPbfwzDCiSLYHWlQ+m6NM 2PGWsRlEswnFmhccYWM1e3/3WgG9OrDX70+Wm0oDn2F0c625AqaBuaPNnSR/Zh0WnWFA EmM4iEs9f2HKopbhy86bghLUinX3bKNRzeb3cJ+pHGmVRumhmQIC8J6s8OmXCZSH1jhw ZfUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=mIeCRU+e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a056402519100b004673015ab88si13287245edd.19.2022.11.22.09.14.01; Tue, 22 Nov 2022 09:14:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=mIeCRU+e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234272AbiKVQie (ORCPT + 90 others); Tue, 22 Nov 2022 11:38:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233162AbiKVQi3 (ORCPT ); Tue, 22 Nov 2022 11:38:29 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10B101F2E4 for ; Tue, 22 Nov 2022 08:38:27 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D479D220D2; Tue, 22 Nov 2022 16:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1669135105; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+I+NFNsrgPcwpbYEM36avO5tqcTUKJxcOE3LZCYPOzk=; b=mIeCRU+eOEDZ+OxRe+gCqjBZczpRwBm/KW58ozh1UH86f5tQUWNDvcunZtdRU/vZhsghVv 5Qyx86hbts/r7eOFaBgz4LnhJvZifALmN1l/dwRLsQGJ6xZYKkZhA/NnS2QQQOLKWFa25m bI3AF5u5BQU60zoM+MW/P+MiIhpuBwA= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 974BC13AA1; Tue, 22 Nov 2022 16:38:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8I+QIwH7fGM0PgAAMHmgww (envelope-from ); Tue, 22 Nov 2022 16:38:25 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v2 2/3] x86/realmode: add trampoline reference structure Date: Tue, 22 Nov 2022 17:38:09 +0100 Message-Id: <20221122163810.29752-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221122163810.29752-1-jgross@suse.com> References: <20221122163810.29752-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new struct trampoline_ref containing the relevant pointers for handling the realmode trampoline. Use a central pointer for accessing this new structure in preparation of adding support of replacing it with a dummy trampoline. Signed-off-by: Juergen Gross --- arch/x86/include/asm/realmode.h | 12 +++++++++++- arch/x86/realmode/init.c | 13 +++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h index 1eb3d4232e81..778d6cb1db6c 100644 --- a/arch/x86/include/asm/realmode.h +++ b/arch/x86/include/asm/realmode.h @@ -14,6 +14,13 @@ #include #include +/* Pointers for installing the realmode trampoline. */ +struct trampoline_ref { + unsigned char *blob; + unsigned char *blob_end; + unsigned char *relocs; +}; + /* This must match data at realmode/rm/header.S */ struct real_mode_header { u32 text_start; @@ -56,6 +63,8 @@ struct trampoline_header { }; extern struct real_mode_header *real_mode_header; +extern struct trampoline_ref *real_mode_trampoline __initdata; + extern unsigned char real_mode_blob_end[]; extern unsigned long initial_code; @@ -78,7 +87,8 @@ extern unsigned char secondary_startup_64_no_verify[]; static inline size_t real_mode_size_needed(void) { - return PAGE_ALIGN(real_mode_blob_end - real_mode_blob); + return PAGE_ALIGN(real_mode_trampoline->blob_end - + real_mode_trampoline->blob); } static inline void set_real_mode_mem(phys_addr_t mem) diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c index 37a3658efaa0..5a670a9ed2f7 100644 --- a/arch/x86/realmode/init.c +++ b/arch/x86/realmode/init.c @@ -12,6 +12,15 @@ #include struct real_mode_header *real_mode_header; + +static __initdata struct trampoline_ref realmode_trampoline = { + .blob = real_mode_blob, + .blob_end = real_mode_blob_end, + .relocs = real_mode_relocs, +}; + +struct trampoline_ref *real_mode_trampoline __initdata = &realmode_trampoline; + u32 *trampoline_cr4_features; /* Hold the pgd entry used on booting additional CPUs */ @@ -111,12 +120,12 @@ static void __init setup_real_mode(void) if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) set_memory_decrypted((unsigned long)base, size >> PAGE_SHIFT); - memcpy(base, real_mode_blob, size); + memcpy(base, real_mode_trampoline->blob, size); phys_base = __pa(base); real_mode_seg = phys_base >> 4; - rel = (u32 *) real_mode_relocs; + rel = (u32 *) real_mode_trampoline->relocs; /* 16-bit segment relocations. */ count = *rel++; -- 2.35.3