From nobody Wed Aug 31 01:32:10 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MHRVg1VnNz4bqCH; Wed, 31 Aug 2022 01:32:11 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MHRVg0gjZz3CRv; Wed, 31 Aug 2022 01:32:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661909531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EMAJYskyEIK5d90N7M7CfNOurPjx4uA3rUmXczaO4PM=; b=x4cpakTK92RxUv9N1zqPwuL5WNpplKj2oC0oLM1DPnziJlK/IyVDnzo6J7lqPx/+alcvkn i0tn4Qi+0+yrVjSCwozSa8EW+redeK64lMB/wf44ouojCz0IKoEcHXTipAZFW9a2eh+eHP VSK+wtKWYmGpYsQ5/ryPlwYqgIlIr1hCmtWgDzVydyCmmAr9zYFvPMgLKFqbOfBjhtQ6q5 iUzoqa365raLwzSPB8UoF4YQCAR4f2oHQC5pNjjbO0haM9AGjQhQyXqsRMBCbwu91VxNAE axDlYxrwtOPcwi2cioLu5vEAD7WdNzOgHG05ll3++0UXY9tJYly6WxZzY0/wCQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MHRVf6rB5zy2N; Wed, 31 Aug 2022 01:32:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27V1WAwR032668; Wed, 31 Aug 2022 01:32:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27V1WAZQ032667; Wed, 31 Aug 2022 01:32:10 GMT (envelope-from git) Date: Wed, 31 Aug 2022 01:32:10 GMT Message-Id: <202208310132.27V1WAZQ032667@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 836fcf84616a - stable/13 - i386 copyout_fast: improve detection of a fault on accessing userspace List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 836fcf84616a45c5c026610ee813996c44cdb9ba Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661909531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EMAJYskyEIK5d90N7M7CfNOurPjx4uA3rUmXczaO4PM=; b=C16hEQdqSZCYQtDQPsMCWquOuDrAoXlMlBCseoSM7ePtYOxMeo1eHXBbEsseivh7+Rs6tw VT3lYZX59zEU5YFzfauNNeEsQTuL6IoMIjH7xrzOnMajU4zVOE6drfrGNf3C/PkKY0ZX2I Xnf4BFPBqtHNVYrr9Kb2KhUh/pUsjJql6a9C7ao25+PN+ZlsCqi7IPUnpPQ21znpkSXFb1 Tzprer2slQGGSRTLwGD8GganeJt8fCrZBnCeFOS+5UDRcmcr1+oMAiMWx15zvmqD4u1EzB AV8e39MEyrCDmlOdsFBBdkmUjwWvlLSAExJg+mjQGFcKHcoA6O4M29KX0an4/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661909531; a=rsa-sha256; cv=none; b=tEY2lbq/YLGNdLAh8j2iy3AV1kcu1SxecTun857KwAvYr3mwPYvlqWUjH2qllCExJjalUG KCbvL4LFEoYtt8EdtkQwSDCHla6E004tP2lUmwb55h1by5IxhIL7kkUjA6pbNR1vm8Wd80 TN4CaCR8rB+J3/PDdT3bG0tzfjKX1ajn0RzQ9VeMVTGMRYjg6cYM7allqhHBmcnX1JW/hh 89DxXPz13O0bmEp4AOAddpGsrR5sRaJl9NhsigsymwFSC4N6jXXwhdD+GkC6Tyoyn4a6x3 J/Rk0v9/7neZF+gAlJeb9r5z9EZMGozqdqVWYXlyqOB2uyXjvdSdbFo/a1NrMg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=836fcf84616a45c5c026610ee813996c44cdb9ba commit 836fcf84616a45c5c026610ee813996c44cdb9ba Author: Konstantin Belousov AuthorDate: 2022-08-09 00:56:54 +0000 Commit: Konstantin Belousov CommitDate: 2022-08-31 01:20:27 +0000 i386 copyout_fast: improve detection of a fault on accessing userspace (cherry picked from commit 95f773e59482b1a3462d2fe3901532d51fb053b3) --- sys/i386/i386/copyout_fast.s | 16 ++++++++-------- sys/i386/i386/exception.s | 32 ++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/sys/i386/i386/copyout_fast.s b/sys/i386/i386/copyout_fast.s index 715952f5fe20..d1d17f775872 100644 --- a/sys/i386/i386/copyout_fast.s +++ b/sys/i386/i386/copyout_fast.s @@ -93,7 +93,7 @@ ENTRY(copyout_fast) popl %ecx popl %edi popl %esi - rep; movsb +pf_x1: rep; movsb movl %ebx,%cr3 movl %eax,%esp @@ -150,7 +150,7 @@ ENTRY(copyin_fast) popl %ecx popl %edi popl %esi - rep; movsb +pf_x2: rep; movsb movl %ebx,%cr3 @@ -197,7 +197,7 @@ ENTRY(fueword_fast) cli movl PCPU(TRAMPSTK),%esp movl %eax,%cr3 - movl (%ecx),%eax +pf_x3: movl (%ecx),%eax movl %ebx,%cr3 movl %esi,%esp sti @@ -226,7 +226,7 @@ ENTRY(fuword16_fast) cli movl PCPU(TRAMPSTK),%esp movl %eax,%cr3 - movzwl (%ecx),%eax +pf_x4: movzwl (%ecx),%eax movl %ebx,%cr3 movl %esi,%esp sti @@ -252,7 +252,7 @@ ENTRY(fubyte_fast) cli movl PCPU(TRAMPSTK),%esp movl %eax,%cr3 - movzbl (%ecx),%eax +pf_x5: movzbl (%ecx),%eax movl %ebx,%cr3 movl %esi,%esp sti @@ -291,7 +291,7 @@ ENTRY(suword_fast) cli movl PCPU(TRAMPSTK),%esp movl %eax,%cr3 - movl %edi,(%ecx) +pf_x6: movl %edi,(%ecx) movl %ebx,%cr3 movl %esi,%esp sti @@ -319,7 +319,7 @@ ENTRY(suword16_fast) cli movl PCPU(TRAMPSTK),%esp movl %eax,%cr3 - movw %di,(%ecx) +pf_x7: movw %di,(%ecx) movl %ebx,%cr3 movl %esi,%esp sti @@ -348,7 +348,7 @@ ENTRY(subyte_fast) movl PCPU(TRAMPSTK),%esp movl %eax,%cr3 movl %edi,%eax - movb %al,(%ecx) +pf_x8: movb %al,(%ecx) movl %ebx,%cr3 movl %esi,%esp sti diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s index 4e806e8b3bd9..ac687aa502fb 100644 --- a/sys/i386/i386/exception.s +++ b/sys/i386/i386/exception.s @@ -133,17 +133,41 @@ IDTVEC(prot) jmp irettraps IDTVEC(page) testl $PSL_VM, TF_EFLAGS-TF_ERR(%esp) - jnz 1f + jnz 4f testb $SEL_RPL_MASK, TF_CS-TF_ERR(%esp) - jnz 1f + jnz 4f cmpl $PMAP_TRM_MIN_ADDRESS, TF_EIP-TF_ERR(%esp) - jb 1f + jb 4f + pushl %eax + movl TF_EIP-TF_ERR+4(%esp), %eax + addl $1f, %eax + call 5f +1: cmpl $pf_x1, %eax + je 2f + cmpl $pf_x2, %eax + je 2f + cmpl $pf_x3, %eax + je 2f + cmpl $pf_x4, %eax + je 2f + cmpl $pf_x5, %eax + je 2f + cmpl $pf_x6, %eax + je 2f + cmpl $pf_x7, %eax + je 2f + cmpl $pf_x8, %eax + jne 3f +2: popl %eax movl %ebx, %cr3 movl %edx, TF_EIP-TF_ERR(%esp) addl $4, %esp iret -1: pushl $T_PAGEFLT +3: popl %eax +4: pushl $T_PAGEFLT jmp alltraps +5: subl (%esp), %eax + retl IDTVEC(rsvd_pti) IDTVEC(rsvd) pushl $0; TRAP(T_RESERVED)