From nobody Thu May 15 14:01:50 2025 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 4ZysMf65Xkz5wP21; Thu, 15 May 2025 14:01:50 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZysMf3p2Rz3QYq; Thu, 15 May 2025 14:01:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747317710; 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=lDGdvCdTxEcJM/Vsd3869t7y+72Js9QbnMJmPWWs7Os=; b=canzHD7Orj29Cfeit3cmd6HPG4El3HAF+85X+QQC11xycR8VmkRL0VxTLifiXiQbe8894J HbdzaYJ4PqhjKlPDX5yyvk5A72mq9RW1cd0xhlEcX7Zxro8DYOTZ66gO++2ZttrkUUiTnh kyNXf81Iv7eWrwGKgsPrM3Y3oNqveOsoPjl7OcXKtjysp52mSH2MfyofIofMy727Y0rf6Z aI+4Fcs9vT5cpjT1uXn92dNhjyl14EYFL3W1oVjbZLpAoZY41uPkv9UDK9DviX5HaC1AEn pGAmS6ahzH6qqvLuaVUL2OhyRYxmU7SCsXGchp1dJmsCqmvdarhQfHoa2hoteA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747317710; 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=lDGdvCdTxEcJM/Vsd3869t7y+72Js9QbnMJmPWWs7Os=; b=JOK89w9pgqyX4n99NP5KhMBj9p3QFDl4XmM5HSx+Z/FVEXSJNPCvfrls71jheYkvOxzxiW N2yUd0MtxextnPNPdJMP7ESJqxmXC7AR9N/1pXYr+FsmglIrjmuZjMp7Vd8FxVVX2hVGHa 6/t1LKqLU7TKxmFJQSGmTk+wQ1CE2KACy515aE3CSavXixMovC+f6XVDWc6dKp/GIQrDHr O+b0hFU5FxhPgLcz/nT5FjeeeKW2UKI9kEqrK2R1Gs5H0IaunHXelPrvMguMUtDpzMBP6T Rgu4wzIi3y5xsMTlvU6eZL5Ff++ASJiJq0xq6ruJRpR/TXUH7yAKr4DJS68Puw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1747317710; a=rsa-sha256; cv=none; b=DhrSC07mIlP4ev8yhtWhvTDK0KKw748qeSoGBP4gGNWgHH80ksUt1DKCRRq0cuctXgnUbw LLLRZlAVaeMKh8YFllW/+evO/WgqLCNdN+U3UEO+0/aZ8xtmJ/QEvcigBIveKCmZHHDOdB c3J/MoyUrusfSKWczXCcNWgkCwzzDxgQyrUwV4+I/jCR655alTK+eYQ72nz847/A3lvqPI kW3gOE5YMWZPntws27K8kKFdYtiS2XlIBWYSBNR27V+oqzam4CHuIuJVWGoTi4iBDEjltu 3mlDB+wUele6x9Oj9eSVdPEIUZCIelg1y53/fvMYq+Q2Yno9HYNG2zqK/DdUOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4ZysMf3BpZz5VZ; Thu, 15 May 2025 14:01:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 54FE1oqg018607; Thu, 15 May 2025 14:01:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54FE1o4t018604; Thu, 15 May 2025 14:01:50 GMT (envelope-from git) Date: Thu, 15 May 2025 14:01:50 GMT Message-Id: <202505151401.54FE1o4t018604@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: e9131d5545d5 - main - bhyve aarch64: generate SError exception when accessing non-backed gpa 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/main X-Git-Reftype: branch X-Git-Commit: e9131d5545d56c7c9a2922bd745812ae2cd7426f Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e9131d5545d56c7c9a2922bd745812ae2cd7426f commit e9131d5545d56c7c9a2922bd745812ae2cd7426f Author: Konstantin Belousov AuthorDate: 2025-05-09 09:08:46 +0000 Commit: Konstantin Belousov CommitDate: 2025-05-15 14:01:40 +0000 bhyve aarch64: generate SError exception when accessing non-backed gpa Reviewed by: andrew Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50116 --- usr.sbin/bhyve/aarch64/Makefile.inc | 2 +- usr.sbin/bhyve/aarch64/mem_aarch64.c | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/aarch64/Makefile.inc b/usr.sbin/bhyve/aarch64/Makefile.inc index 9f187a6e4db7..7c1417ec6956 100644 --- a/usr.sbin/bhyve/aarch64/Makefile.inc +++ b/usr.sbin/bhyve/aarch64/Makefile.inc @@ -1,6 +1,6 @@ SRCS+= \ fdt.c \ - mem_md.c \ + mem_aarch64.c \ rtc_pl031.c \ uart_pl011.c diff --git a/usr.sbin/bhyve/aarch64/mem_aarch64.c b/usr.sbin/bhyve/aarch64/mem_aarch64.c new file mode 100644 index 000000000000..902d16fa7c51 --- /dev/null +++ b/usr.sbin/bhyve/aarch64/mem_aarch64.c @@ -0,0 +1,58 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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. + */ + +#include +#define _WANT_KERNEL_ERRNO 1 +#include +#include +#include +#include +#include +#include + +#include "mem.h" + +int +mmio_handle_non_backed_mem(struct vcpu *vcpu, uint64_t paddr, + struct mem_range **mr_paramp __unused) +{ + int err; + uint64_t spsr, esr; + + if (vm_get_register(vcpu, VM_REG_GUEST_CPSR, &spsr) == -1) + return (errno); + if ((spsr & PSR_M_MASK) == PSR_M_EL0t) + esr = EXCP_DATA_ABORT_L << ESR_ELx_EC_SHIFT; + else + esr = EXCP_DATA_ABORT << ESR_ELx_EC_SHIFT; + esr |= ESR_ELx_IL | ISS_DATA_DFSC_EXT; + err = vm_inject_exception(vcpu, esr, paddr); + return (err != 0 ? err : EJUSTRETURN); +}