From nobody Fri May 17 16:12:51 2024 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 4VgsSN1Pbmz5LPF8; Fri, 17 May 2024 16:12:52 +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 4VgsSM6DFmz4Q7N; Fri, 17 May 2024 16:12:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715962371; 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=NxZtLB4xfo1VgLaQvMKkqYU2oBrdgeeeay+0xxEp97w=; b=gb7Q+TcgPvfbQgzD/XmITwcnfL97tQ1o16FhtdmTKBkzQ8Efs4YUBj2L0hOobgPz3D6HpU Unj894qSz0G+fy7x8XlsuftVrdlvZJw/y2wIK296aF/o35I9glUqijMB0/JfsDOLknQPQg VUxC3YCW4uH0BBIJAaUt0uaLY4rPvP6J3lutwIbr4jG2ch8klqih3RVsfas6vmIfVzzt7U ee4VRCwNLHpTWxc4GIQKQsUvsnWmbOW23ak4vKkysLVDCeIxhYAhYu4hQrT6jU1LzwSbBW J7jlsxAPJzSfvlMJhOYGlf8R3uUvjKvvOz9+085H8X6LANHb2/fd+Jzr3WjdTQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715962371; a=rsa-sha256; cv=none; b=ROfM6L3GvTPQvpokuYq/VZLItr+jdcnHwqD69m0sSWkL0OofGmqxtMWQXKkGJYNDCeLqLW SGDLOhWMZrxhnAeC2hLIctZocFRZKPBxpa52V9/BmR3WsAPBNeRk019zZO0KyRf5mcP74X 31v5NexuPY/MNuB84YNTuZfOY1QwFiOpoinywVUcEbc9jbVtX//tQs257iHnP2RK+22yjf iY70IkAng1mKSZ3FpgGZnnUu+70tAByxV2p9FAOMlCfQgaAD+syUP+BMnUpJ+G17j6jzxG iIS8DumCBMEqLsJgCQMEIMKGFoarQerpr7/bMII3RtySlYIypgBNX1LfKGYG1Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715962371; 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=NxZtLB4xfo1VgLaQvMKkqYU2oBrdgeeeay+0xxEp97w=; b=YEX76/MHT55lgLn31LEWc9i21KHgVFFXNxHN6hLJHYpO51iwnJTCZpZimcjVk7RRNHN0I4 x8TIxJgc+VCq9n3CqjGfkEvlTXsn2ZCwP8Dh8xpCXkP+lU/Z4KdIeX29ATJnLlWHFdOHi3 fNcNv5Tom5KqegMpxHcsMrpK0h0C7U7pNUe+G+sg7S1qguJAEtSzzpCrhtsBR7Q5Yf9IdD dXd6VBFz3pAeVfx3+rTmVOEY9SRsNxPuKkih6qDXw6VO76Wz9ZmMz9hdX4kcprEr/qH1mg FRhp2lV1D1Ap05TNqaotliZEYTbTnZFrHrK6ixPkQQPcJ+FKy0xpcjDC4ymshA== 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 4VgsSM4krdzpxv; Fri, 17 May 2024 16:12:51 +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 44HGCp32065172; Fri, 17 May 2024 16:12:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44HGCpn1065169; Fri, 17 May 2024 16:12:51 GMT (envelope-from git) Date: Fri, 17 May 2024 16:12:51 GMT Message-Id: <202405171612.44HGCpn1065169@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: e72c41772352 - main - arm: Use the correct irq when in the hypervisor 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e72c41772352e1165711900c4f8df6b15b842ba8 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=e72c41772352e1165711900c4f8df6b15b842ba8 commit e72c41772352e1165711900c4f8df6b15b842ba8 Author: Andrew Turner AuthorDate: 2024-01-11 17:13:12 +0000 Commit: Andrew Turner CommitDate: 2024-05-17 16:07:16 +0000 arm: Use the correct irq when in the hypervisor When booting in the hypervisor state we need to use the hypervisor interrupt in the generic timer. In this case the registers we access in the kernel are remapped to the EL2 versions, however this causes an unexpected interrupt to trigger. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D43975 --- sys/arm/arm/generic_timer.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/sys/arm/arm/generic_timer.c b/sys/arm/arm/generic_timer.c index bad0939b6ab9..d3e264527a7f 100644 --- a/sys/arm/arm/generic_timer.c +++ b/sys/arm/arm/generic_timer.c @@ -171,12 +171,14 @@ static struct timecounter arm_tmr_timecount = { #define set_el0(x, val) cp15_## x ##_set(val) #define set_el1(x, val) cp15_## x ##_set(val) #define HAS_PHYS true +#define IN_VHE false #else /* __aarch64__ */ #define get_el0(x) READ_SPECIALREG(x ##_el0) #define get_el1(x) READ_SPECIALREG(x ##_el1) #define set_el0(x, val) WRITE_SPECIALREG(x ##_el0, val) #define set_el1(x, val) WRITE_SPECIALREG(x ##_el1, val) #define HAS_PHYS has_hyp() +#define IN_VHE in_vhe() #endif static int @@ -678,13 +680,22 @@ arm_tmr_attach(device_t dev) #endif #ifdef __aarch64__ - /* - * Use the virtual timer when we can't use the hypervisor. - * A hypervisor guest may change the virtual timer registers while - * executing so any use of the virtual timer interrupt needs to be - * coordinated with the virtual machine manager. - */ - if (!HAS_PHYS) { + if (IN_VHE) { + /* + * The kernel is running at EL2. The EL0 timer registers are + * re-mapped to the EL2 version. Because of this we need to + * use the EL2 interrupt. + */ + sc->physical_sys = true; + first_timer = GT_HYP_PHYS; + last_timer = GT_HYP_PHYS; + } else if (!HAS_PHYS) { + /* + * Use the virtual timer when we can't use the hypervisor. + * A hypervisor guest may change the virtual timer registers + * while executing so any use of the virtual timer interrupt + * needs to be coordinated with the virtual machine manager. + */ sc->physical_sys = false; first_timer = GT_VIRT; last_timer = GT_VIRT;