From owner-svn-src-all@freebsd.org Fri May 8 14:38:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 79F662D8E18; Fri, 8 May 2020 14:38:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49JXyK2XPCz3NBh; Fri, 8 May 2020 14:38:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 525563E1B; Fri, 8 May 2020 14:38:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 048Ecndo056213; Fri, 8 May 2020 14:38:49 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 048Ecn3U056212; Fri, 8 May 2020 14:38:49 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202005081438.048Ecn3U056212@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 8 May 2020 14:38:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360812 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 360812 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.32 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 May 2020 14:38:49 -0000 Author: markj Date: Fri May 8 14:38:48 2020 New Revision: 360812 URL: https://svnweb.freebsd.org/changeset/base/360812 Log: Reinitialize thread0's stack base after enabling XSAVE. Otherwise the initial call to set_top_of_stack(), which occurs before fpuinit() sets the correct value for cpu_max_ext_state_size, leaves the stack base at an incorrect location. Then, when the full area is zeroed, we end up erroneously zeroing part of the following page. Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24754 Modified: head/sys/amd64/amd64/machdep.c Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Fri May 8 14:13:30 2020 (r360811) +++ head/sys/amd64/amd64/machdep.c Fri May 8 14:38:48 2020 (r360812) @@ -1857,7 +1857,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) setidt(IDT_IO_INTS + 15, IDTVEC(spuriousint), SDT_SYSIGT, SEL_KPL, 0); #endif #else -#error "have you forgotten the isa device?"; +#error "have you forgotten the isa device?" #endif if (late_console) @@ -1867,12 +1867,13 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) fpuinit(); /* - * Set up thread0 pcb save area after fpuinit calculated fpu save - * area size. Zero out the extended state header in fpu save - * area. + * Reinitialize thread0's stack base now that the xsave area size is + * known. Set up thread0's pcb save area after fpuinit calculated fpu + * save area size. Zero out the extended state header in fpu save area. */ + set_top_of_stack_td(&thread0); thread0.td_pcb->pcb_save = get_pcb_user_save_td(&thread0); - bzero(get_pcb_user_save_td(&thread0), cpu_max_ext_state_size); + bzero(thread0.td_pcb->pcb_save, cpu_max_ext_state_size); if (use_xsave) { xhdr = (struct xstate_hdr *)(get_pcb_user_save_td(&thread0) + 1); @@ -1882,7 +1883,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) rsp0 = thread0.td_md.md_stack_base; /* Ensure the stack is aligned to 16 bytes */ rsp0 &= ~0xFul; - __pcpu[0].pc_common_tss.tss_rsp0 = rsp0; + PCPU_PTR(common_tss)->tss_rsp0 = rsp0; amd64_bsp_pcpu_init2(rsp0); /* transfer to user mode */