Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4994601iog; Wed, 22 Jun 2022 09:45:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u7npzXHcEPyBCF2kcBdea0SBJtQAMXMxhRQkmcJp8C0n5ysLI9xC9Wms26YVdzSTueYHjk X-Received: by 2002:a05:6a00:2181:b0:51b:560b:dd30 with SMTP id h1-20020a056a00218100b0051b560bdd30mr36455485pfi.44.1655916302757; Wed, 22 Jun 2022 09:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655916302; cv=none; d=google.com; s=arc-20160816; b=Ndf4OBq2S0WahAmG3OdGScpHoRFfu5Fh2eI1P7hr8BJcGaw4TxGFeTDhP7/m8lE3zC jJCrtLBoekZ5aM793e+tf4JIzO9Nt4bZidixNdqGzCLXabta9Ki0z6owkJfUJ3MidMaN 8/0ue67/G69dEbpImKqe3q4AGkWJ7ZONRYMeUweF8kIdTfYmS+onWzb4fRLfrpoLY8D5 0XaghGwu6uPBLSAFA73epHCMj2ZggfnYiNE7sAD4PCuQBzml3/Lkws5TY+M1qspleHdz XeT9rO3WRWw+MnnPPSa3p6r0pxG33jb49i0Ydm6kZ796hFNECUdmqO3fj6WbrPMB5q8t mDaA== 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=NZVsJ9w6p52CGnx+whse0Q5jtOMx+D4jAJ62tq6HNaI=; b=FW0L7Cx7SeRloGEhhf+hwnwevTEUwpZuoSjPrK2R31IjbmdRYHh5tP6aPhMZeSge0i 177o0ZKzPnPGB/yhPZj9Jt370YzT5owj9+JFy8aTN+u2e59YYcCAyfWlm2ZAFslpm7Rx TIPRg/nzdBJiNCvHWTyFpGoDjcN5tgWHcqAejwCVRCdAU526PVdwV1RAHiy0vEShWY1t GrD9x0jdD1Y7UX+XsqAQabrZdEBegCg3NnihPiiM8WZchRf8vL27paRQJXgVNFHmeLBe uJBgPTgdC/hF/nEyyvzF8V2P3JH8pBRo+KhJ7I/lzh6av2zGcoNrBdY75DFjINYWR/kB rzZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=cd42wzcG; 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 y21-20020a634955000000b003fc48964390si24667817pgk.613.2022.06.22.09.44.51; Wed, 22 Jun 2022 09:45:02 -0700 (PDT) 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=cd42wzcG; 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 S1359330AbiFVQK5 (ORCPT + 99 others); Wed, 22 Jun 2022 12:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359222AbiFVQKx (ORCPT ); Wed, 22 Jun 2022 12:10:53 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F27D3ED0B for ; Wed, 22 Jun 2022 09:10:53 -0700 (PDT) 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-out2.suse.de (Postfix) with ESMTPS id C43681F8E0; Wed, 22 Jun 2022 16:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655914251; 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=NZVsJ9w6p52CGnx+whse0Q5jtOMx+D4jAJ62tq6HNaI=; b=cd42wzcG9qaMXbWjJjPT6DeqeIeIraiBDdVXY8uFDunVR1bsFtlTkWabujY1sWEZYk3rPh g4T4IjxBOE8PIn0qEs6huxZI6p+qO7eNMCH7djqwSi30jRTgnY3Cy3I7CN1UN56ydHzj/A 48WC5iBIXNOX5SPuKT343/uLBidXZg0= 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 6E999134A9; Wed, 22 Jun 2022 16:10:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8GO1GQs/s2JzCwAAMHmgww (envelope-from ); Wed, 22 Jun 2022 16:10:51 +0000 From: Juergen Gross To: xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Boris Ostrovsky Subject: [PATCH 1/2] x86/xen: use clear_bss() for Xen PV guests Date: Wed, 22 Jun 2022 18:10:47 +0200 Message-Id: <20220622161048.4483-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220622161048.4483-1-jgross@suse.com> References: <20220622161048.4483-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,T_SCC_BODY_TEXT_LINE 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 Instead of clearing the bss area in assembly code, use the clear_bss() function. This requires to pass the start_info address as parameter to xen_start_kernel() in order to avoid the xen_start_info being zeroed again. Signed-off-by: Juergen Gross --- arch/x86/include/asm/setup.h | 3 +++ arch/x86/kernel/head64.c | 2 +- arch/x86/xen/enlighten_pv.c | 8 ++++++-- arch/x86/xen/xen-head.S | 10 +--------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index f8b9ee97a891..f37cbff7354c 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h @@ -120,6 +120,9 @@ void *extend_brk(size_t size, size_t align); static char __brk_##name[size] extern void probe_roms(void); + +void clear_bss(void); + #ifdef __i386__ asmlinkage void __init i386_start_kernel(void); diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index bd4a34100ed0..e7e233209a8c 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -426,7 +426,7 @@ void __init do_early_exception(struct pt_regs *regs, int trapnr) /* Don't add a printk in there. printk relies on the PDA which is not initialized yet. */ -static void __init clear_bss(void) +void __init clear_bss(void) { memset(__bss_start, 0, (unsigned long) __bss_stop - (unsigned long) __bss_start); diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index e3297b15701c..70fb2ea85e90 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -1183,15 +1183,19 @@ static void __init xen_domu_set_legacy_features(void) extern void early_xen_iret_patch(void); /* First C function to be called on Xen boot */ -asmlinkage __visible void __init xen_start_kernel(void) +asmlinkage __visible void __init xen_start_kernel(struct start_info *si) { struct physdev_set_iopl set_iopl; unsigned long initrd_start = 0; int rc; - if (!xen_start_info) + if (!si) return; + clear_bss(); + + xen_start_info = si; + __text_gen_insn(&early_xen_iret_patch, JMP32_INSN_OPCODE, &early_xen_iret_patch, &xen_iret, JMP32_INSN_SIZE); diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index 3a2cd93bf059..13af6fe453e3 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -48,15 +48,6 @@ SYM_CODE_START(startup_xen) ANNOTATE_NOENDBR cld - /* Clear .bss */ - xor %eax,%eax - mov $__bss_start, %rdi - mov $__bss_stop, %rcx - sub %rdi, %rcx - shr $3, %rcx - rep stosq - - mov %rsi, xen_start_info mov initial_stack(%rip), %rsp /* Set up %gs. @@ -71,6 +62,7 @@ SYM_CODE_START(startup_xen) cdq wrmsr + mov %rsi, %rdi call xen_start_kernel SYM_CODE_END(startup_xen) __FINIT -- 2.35.3