From nobody Wed Oct 05 21:15:01 2022 X-Original-To: dev-commits-src-branches@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 4MjS5K6gwYz4f5LJ; Wed, 5 Oct 2022 21:15:01 +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 4MjS5K6BSpz3FKn; Wed, 5 Oct 2022 21:15:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665004501; 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=48Gdg33fBuYHYOM8at2/rEzzqtmiJ0vCZMBHPrEGXH8=; b=o10RLju7Ywlf4gfPVe2VFAu1AjzLT5NyHpocHeXUO8PwDAtmJpTgJW2kHBietGflQ87kuN NHEb3IYwh1RwU1wVxZdV3zuOrYhxBhgkLEAjtT27/yLrVdLKR1LdTXRv5inzZvtFOThXMF +WZkUdEiWpGjgpA3OyBJgrSXtFC+5BgEUzlO7qqrTGOwWkPIPvefKlXzEyXKMZ8zWwfK25 SZIYvgklaC4OPfMK2aA1LlxCY4PCZq08gooKivfqo6eZjmlEbYU8FpoQJUEUpdlf3nbLWb RZZuPdwO/V/QtnmTAhbJUHiJwtmB9O9icTnRTIb3YDSzLwmlXV+i1Skwzd8APg== 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 4MjS5K51sqz12X9; Wed, 5 Oct 2022 21:15:01 +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 295LF1uC001095; Wed, 5 Oct 2022 21:15:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 295LF1pt001094; Wed, 5 Oct 2022 21:15:01 GMT (envelope-from git) Date: Wed, 5 Oct 2022 21:15:01 GMT Message-Id: <202210052115.295LF1pt001094@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alfredo Dal'Ava Junior" Subject: git: 05f9810b3197 - stable/13 - powerpc: cpuset: add local functions for copyin/copyout List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 05f9810b31973fb0d5f07a6eb9a12a22f81c38ad Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665004501; 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=48Gdg33fBuYHYOM8at2/rEzzqtmiJ0vCZMBHPrEGXH8=; b=DaNvL8LoggGozqkREWi/pGp0lSrLwhqVSfsCQGBDvNDTQyK7xa9VpJSLknet4MHgkxoHaa Mrm6tnAKBjicgSPqpLT9cg8A4C+w/XLfdLvg8kDCt+la7dQhz0JayKBo9kR0PY775y7y6Y gWz2mFmHlTmE7FlyRL54DufiQkGAKQtPE6wSpGrqVorPqOVVpRxAZWK42wqSOk5KLnhVW6 JoEdHaUC1cauHqDuBwoohkR/QqQiINkJg0XKoaJnUt/3Gd9vn7l9U3QZaQ2+SzNrbcRc7n 8xbMHTSUOw42JSEFU8TVGUMTfHI03AxZsP6DN8AbB0zYQuc7NJkTj2bOMhKEvA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665004501; a=rsa-sha256; cv=none; b=fKGrLnl4N4vryjhc1LgAMVcbVX+wucqoFqFtMv5NFYH2RzYa3BctEayjIoSFjv0mzl3Ojo 8W4tz4ondWy/G3/TMHPc3TPWUcCZfHFD/co3nWnQFqBwwf5JOfSa/gCq3mAdH1B1LypSNA sYX48m5hNxcRj3/7s/Z04ilEEhrDG1N3RLuFAaGllONJYQbUeCBUfmw4y8sK8W034I7lCw P7W6oV7rJNoLfGmwfczsOqjou/oWjfeMZ8bLMHoEBEkSmI9OoffKUYj4dZPQkKJBXYSEE1 f7AjOces5ygj6HTuSwzlkDWpd6wQUwJ6TfzOIL3QveyJ52lO1kIcfGQ4sVpo7g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=05f9810b31973fb0d5f07a6eb9a12a22f81c38ad commit 05f9810b31973fb0d5f07a6eb9a12a22f81c38ad Author: Alfredo Dal'Ava Junior AuthorDate: 2022-10-03 14:51:05 +0000 Commit: Alfredo Dal'Ava Junior CommitDate: 2022-10-06 00:14:19 +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 (cherry picked from commit db79bf75ac9eb1b5678ccbaebb45fb88c0e0e1e3) --- 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 0670d9a046a7..affc48e78862 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 {