Commit 50e43532c2 for qemu.org

commit 50e43532c2f6effd8e77e6a01cc737736fcb4f30
Author: Keith Monahan <keith@techtravels.org>
Date:   Fri Nov 20 18:12:30 2026 +0100

    hw/scsi/ncr53c710: Append SAVE DATA POINTERS after MESSAGE REJECT for HP-UX

    The HP-UX 10.20 install kernel is nonconformant: its self modifying
    SCRIPTS reads a second message byte after the MESSAGE REJECT that
    declines SDTR/WDTR/PPR negotiation and hangs unless it is SAVE DATA
    POINTERS, while NetBSD's osiop resets the bus if it sees that byte.
    The two are told apart by ATN state as the reject is consumed (HP-UX
    has deasserted ATN, a conformant initiator has not), so the extra byte
    is appended only for HP-UX.

    Signed-off-by: Keith Monahan <keith@techtravels.org>
    AI-used-for: Patch series decomposition (commit splitting and ordering)
    Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
    Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c
index 25469c7d7d..39a20ba90e 100644
--- a/hw/scsi/ncr53c710.c
+++ b/hw/scsi/ncr53c710.c
@@ -700,6 +700,10 @@ static void lsi_do_msgin(NCR710State *s)
     if (!s->msg_len) {
         switch (s->msg_action) {
         case LSI_MSG_ACTION_COMMAND:
+            /* A MESSAGE REJECT declining negotiation was just consumed. */
+            if (s->sfbr == 7 && !(s->socl & LSI_SOCL_ATN)) {
+                lsi_add_msg_byte(s, 2);   /* SAVE DATA POINTERS (HP-UX) */
+            }
             /* Stay in MSG IN until the next block move requests COMMAND. */
             break;
         case LSI_MSG_ACTION_DISCONNECT:
@@ -795,7 +799,12 @@ static void lsi_do_msgout(NCR710State *s)
     }
     return;
 reject:
-    /* Decline SDTR/WDTR/PPR negotiation with a single MESSAGE REJECT. */
+    /*
+     * Decline SDTR/WDTR/PPR negotiation with a single MESSAGE REJECT.  HP-UX
+     * requires a trailing SAVE DATA POINTERS (0x02), which other initiators
+     * reject.  HP-UX reads the reject with ATN deasserted, so lsi_do_msgin
+     * appends the 0x02 only then.
+     */
     lsi_set_phase(s, PHASE_MI);
     lsi_add_msg_byte(s, 7);           /* MESSAGE REJECT */
     s->msg_action = LSI_MSG_ACTION_COMMAND;