From bcc504a01cee79955e409ebed7db1fcecc409e98 Mon Sep 17 00:00:00 2001 From: miod Date: Tue, 2 Aug 2022 20:15:28 +0000 Subject: [PATCH] Correctly detect xmem operations faulting on missing pages on 88110. These must be handled as write faults rather than read faults, since xmem performs both a read and a write, and unlike on 88100, we don't have an easy bit to check. This solves libcrypto spinning on its locks on 88110. --- sys/arch/m88k/m88k/trap.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c index 28cdc6be601..ee542f34ba7 100644 --- a/sys/arch/m88k/m88k/trap.c +++ b/sys/arch/m88k/m88k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.120 2021/12/09 00:26:11 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.121 2022/08/02 20:15:28 miod Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -868,7 +868,17 @@ m88110_user_fault: #endif } else { fault_addr = frame->tf_dlar; - if (frame->tf_dsr & CMMU_DSR_RW) { + /* + * Unlike the 88100, there is no specific bit telling + * us this is the read part of an xmem operation. + * However, if the WE (Write Exception) bit is set, + * then obviously this is not a read fault. + * But the value of this bit can not be relied upon + * if either PI or SI are set... + */ + if ((frame->tf_dsr & CMMU_DSR_RW) != 0 && + ((frame->tf_dsr & (CMMU_DSR_PI|CMMU_DSR_SI)) != 0 || + (frame->tf_dsr & CMMU_DSR_WE) == 0)) { access_type = PROT_READ; fault_code = PROT_READ; } else { -- 2.20.1