From nobody Mon Oct 03 12:02:57 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 4MgzxG2DKNz4dqG7; Mon, 3 Oct 2022 12:02:58 +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 4MgzxG1kR6z3qCR; Mon, 3 Oct 2022 12:02:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664798578; 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=sPymJFX69EciT+gF0wSvgHRNvA7Y8erRRYtoYYWK5cI=; b=GofL4YeZU1LZBpICCcf8e9BkjhJv77dFRZgFoG+R8TUkSzbxD39Ao6u9MwTWN1pn5SaVRM PToDP8SXuMNyc5rRhDaXpc9DMm/4Ki+O8k6/qzqVIlpRICSZ1PhUB5vqigpONmUsaDrhCi ch9yW6M4lAWam8i/8aav0q+Ky57BQGMXiyH+Vg2VALtzXLZ8l55kL+37IqHlDcAZ33bOfo XcyJLquFlMmkN09PSfVFXFnM6U6m+pLp04wiVsouiT4l2O3SKO2qNCyFcm8UHVVpcKn/UG mcIdZcUG680T05DpjdMY2mpZ6bi6y67HroPf1qUaryApVgyK7uuNtWW+FW3G/Q== 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 4MgzxG0mKnz1Brm; Mon, 3 Oct 2022 12:02:58 +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 293C2wDU024214; Mon, 3 Oct 2022 12:02:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 293C2v1m024213; Mon, 3 Oct 2022 12:02:57 GMT (envelope-from git) Date: Mon, 3 Oct 2022 12:02:57 GMT Message-Id: <202210031202.293C2v1m024213@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alfredo Dal'Ava Junior" Subject: git: db79bf75ac9e - main - powerpc: cpuset: add local functions for copyin/copyout 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: alfredo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: db79bf75ac9eb1b5678ccbaebb45fb88c0e0e1e3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664798578; 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=sPymJFX69EciT+gF0wSvgHRNvA7Y8erRRYtoYYWK5cI=; b=biWjuVe5myUH35FS+HmHl/LyIO2OEcr5LS3WrXjdUzdrR1O9zuGcpNMbwSk5cSxkVC0AAX YUlsRSlg+g8KhU4qnWLf8UwDWJpTWYoU5RDGSUru4CatsqvDzUYNxv7D/eoJkx8zR4F/rO VlEIePxZBMGJ8/zyRTHPALcqWkna61QYmfCBxUKm5GksU3Qm/lcl+pNmxiphLxowunw2WL zkBd0P3jbbDyB4pvGFREGE/fm5tET4TN/Jz0pB/kQ+Qc62JQVkwePrlkbpqZVSVmNiFza3 5BYf4V++PRSHVdRzhX4HdrXOf82B/YecHzpodmRrD71lPP/H4bJ1VSV9wFolXw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664798578; a=rsa-sha256; cv=none; b=XEQozCteokrn6WjJbIKgYBTDyH+yxQpxe6PpiHhZAWjq9RTzjulTnkvJdnuybv122kJ5IR ATwq79rFGvttiOzxjEkCT3w1R0GTToKc95RnthM7YU2j0jqsMGNwQKDUrij6oUAr609oWP ahwN6Zvsph8moZg0BtSrNXqRIDijdiPq0+Zt8y2euoT/pSMuTHKjdC1B0u52mlo0GFR4j3 fymNaaBn4t4QPf3mWj1nl+9Q+O4kZWXwBClpSkhkxKDrt0PTIq8d5aVnAVaGXN7mdBwkGX WCA50zu0GNNKxWwtiIEK3Gp72NveeUCqfRXnyslMYNUA0X5v2hUfGgq3CZhSAA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=db79bf75ac9eb1b5678ccbaebb45fb88c0e0e1e3 commit db79bf75ac9eb1b5678ccbaebb45fb88c0e0e1e3 Author: Alfredo Dal'Ava Junior AuthorDate: 2022-10-03 14:51:05 +0000 Commit: Alfredo Dal'Ava Junior CommitDate: 2022-10-03 15:03:09 +0000 powerpc: cpuset: add local functions for copyin/copyout Add local functions to workaround an instruction segment trap (panic) when the indirect functions copyin and copyout are called by an external loadable kernel module (i.e. pfsync, zfs and linuxulator). The crash was triggered by change 47a57144af25a7bd768b29272d50a36fdf2874ba, but kernel binary linked with LLD 9 works fine. LLVM bisect points that LLD behavior chaged after dc06b0bc9ad055d06535462d91bfc2a744b2f589. This is know to affect powerpc targets only and the final fix is still being discussed with the LLVM community. PR: 266730 Reviewed by: luporl, jhibbits (on IRC, previous version) MFC after: 2 days Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D36234 --- sys/kern/kern_cpuset.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index ed0a666c460c..d89be2805759 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -1743,10 +1743,42 @@ cpuset_check_capabilities(struct thread *td, cpulevel_t level, cpuwhich_t which, return (0); } +#if defined(__powerpc__) +/* + * TODO: At least powerpc64 and powerpc64le kernels panic with + * exception 0x480 (instruction segment exception) when copyin/copyout, + * are set as a function pointer in cpuset_copy_cb struct and called by + * an external module (like pfsync). Tip: copyin/copyout have an ifunc + * resolver function. + * + * Bisect of LLVM shows that the behavior changed on LLVM 10.0 with + * https://reviews.llvm.org/rGdc06b0bc9ad055d06535462d91bfc2a744b2f589 + * + * This is a hack/workaround while problem is being discussed with LLVM + * community + */ +static int +cpuset_copyin(const void *uaddr, void *kaddr, size_t len) +{ + return(copyin(uaddr, kaddr, len)); +} + +static int +cpuset_copyout(const void *kaddr, void *uaddr, size_t len) +{ + return(copyout(kaddr, uaddr, len)); +} + static const struct cpuset_copy_cb copy_set = { - .cpuset_copyin = copyin, - .cpuset_copyout = copyout + .cpuset_copyin = cpuset_copyin, + .cpuset_copyout = cpuset_copyout }; +#else +static const struct cpuset_copy_cb copy_set = { + .cpuset_copyin = copyin, + .cpuset_copyout = copyout +}; +#endif #ifndef _SYS_SYSPROTO_H_ struct cpuset_args {