From nobody Sat Feb 17 21:32:53 2024 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 4TchqB4Z7cz59lDf; Sat, 17 Feb 2024 21:32:54 +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 4Tchq970y0z4h4y; Sat, 17 Feb 2024 21:32:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205574; 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=s0YulwI2cEnRtpn+SMlw4mXhD6SX3yBZK3Z+SB+PqLM=; b=V7VGCVteRVTIMc9ADmxxj1jxuvcdUdxHpgZp1ipejzmQCLBzpBURdknA6oSF3+IZWB3hGR i1i5xrbvVAkTg0fefLcGIhcdc9jmvsNaubBcanQSgaQxnJY4tGqJCJu8qwDpYxJS7g9XFw JaltM7MU3rmgbjzNaO1zv2mdDqyZXW20MA3tXuUeh5/B7jbvPQXtIPkzceAWOGwXF1x6XF sbuenVBoUJk81aAE+kBXQASVEXg+97YZuLRrtu0LaiUocQ1qQcfPQfQXYfR+uor5X8JOHa 4TyO+3AZmBhQuB6ob3CryoCPnPPMTBypa8qd2/sRrxO8xii+Ck63fQzT/WJJSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205574; 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=s0YulwI2cEnRtpn+SMlw4mXhD6SX3yBZK3Z+SB+PqLM=; b=Vbth0SWQAHXBPRuMHf+a88Bee+C6OiJNgCTudj1O4QER/A22oVvFRCUcmeylpfhTNZrXOT EQbe7ugaZDzRTbS/lRsjoPTqvcz95wZEtaDDOGfl55eiEnytpcC1lcy2MwLvNWYbLm4Sfc oFjuIM7n9I0O2eKQg+RrwnglUL8IHp/dqX9nL3Bjk96snn0yG7XnAHQ+Lug6+COmFxgJk3 88ct4hrxSKTd8gUO8K8McHj4sMOwgoxsu7hjHg81Qyk5Bosu7M3AjDIEyx2gJF1FEwt+en U2YDeAAWkBD8uBCiQIoXL8wpmZRId3+FxawXDoitTdYPMm+CAx8LTUQP12vpLg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708205574; a=rsa-sha256; cv=none; b=gUXzZ+EhCQg0U/8jmrluiv/HVlBNDP7aWwRVQBej0OUSPTY8CwlHa2aCXDuXsr1XVHH+4S 1S1iqT8pIrsKt1zgUl4ZB+7gST9nZemIWfDVFT3gAlUFB++aT4bkedzIRMjM/6XA0nSizf rPQfOqizMKiMPryBFYYtfS58FTOc4ISXHCBFrc4GpOTH5LEQU3UhN0duA1UtB0GAKLp1J+ QHAFJJhrrsr5AI16pRKhB4nV1Dk9JEpIOT8KkelKOJkUvjzKhuGku2CAy8Z/p4NFpYT3+X FU+egnkf3OYuz8kWIyvuNPQDQ/S7pl9teRgEq/6nZ9KnvmtDNxB9yGDay/SELw== 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 4Tchq966LkzPJm; Sat, 17 Feb 2024 21:32:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41HLWrOM020532; Sat, 17 Feb 2024 21:32:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41HLWru7020529; Sat, 17 Feb 2024 21:32:53 GMT (envelope-from git) Date: Sat, 17 Feb 2024 21:32:53 GMT Message-Id: <202402172132.41HLWru7020529@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: b62373d46a05 - stable/14 - LinuxKPI: Add xen/xen.h header 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: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: b62373d46a0572a549b02a2a14956954957c5ee5 Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=b62373d46a0572a549b02a2a14956954957c5ee5 commit b62373d46a0572a549b02a2a14956954957c5ee5 Author: Vladimir Kondratyev AuthorDate: 2023-12-24 08:19:58 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-02-17 20:58:37 +0000 LinuxKPI: Add xen/xen.h header It contains proxy-implementation of xen_initial_domain() and xen_pv_domain() required by latest drm-kmod. Sponsored by: Serenity Cyber Security, LLC Reviewed by: manu, bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42797 (cherry picked from commit c612e3c262db6c8256159c4ed39018788017c7e2) --- sys/compat/linuxkpi/common/include/xen/xen.h | 37 +++++++++++++++++++++++++++ sys/compat/linuxkpi/common/src/linux_compat.c | 30 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/xen/xen.h b/sys/compat/linuxkpi/common/include/xen/xen.h new file mode 100644 index 000000000000..16e77724111d --- /dev/null +++ b/sys/compat/linuxkpi/common/include/xen/xen.h @@ -0,0 +1,37 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Serenity Cyber Security, LLC. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _LINUXKPI_XEN_XEN_H_ +#define _LINUXKPI_XEN_XEN_H_ + +#define xen_initial_domain() lkpi_xen_initial_domain() +#define xen_pv_domain() lkpi_xen_pv_domain() + +bool lkpi_xen_initial_domain(void); +bool lkpi_xen_pv_domain(void); + +#endif /* _LINUXKPI_XEN_XEN_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 59ab61a86ec7..b076a66ded77 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -28,6 +28,7 @@ */ #include +#include "opt_global.h" #include "opt_stack.h" #include @@ -99,6 +100,15 @@ #include #endif +#include +#ifdef XENHVM +#undef xen_pv_domain +#undef xen_initial_domain +/* xen/xen-os.h redefines __must_check */ +#undef __must_check +#include +#endif + SYSCTL_NODE(_compat, OID_AUTO, linuxkpi, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "LinuxKPI parameters"); @@ -2596,6 +2606,26 @@ lkpi_get_static_single_cpu_mask(int cpuid) return (&static_single_cpu_mask[cpuid]); } +bool +lkpi_xen_initial_domain(void) +{ +#ifdef XENHVM + return (xen_initial_domain()); +#else + return (false); +#endif +} + +bool +lkpi_xen_pv_domain(void) +{ +#ifdef XENHVM + return (xen_pv_domain()); +#else + return (false); +#endif +} + static void linux_compat_init(void *arg) {