pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/emulators/qemu



Module Name:    pkgsrc
Committed By:   thorpej
Date:           Fri Nov 20 16:43:05 UTC 2026

Modified Files:
        pkgsrc/emulators/qemu: Makefile distinfo
        pkgsrc/emulators/qemu/patches: patch-hw_rtc_mc146818rtc.c
Added Files:
        pkgsrc/emulators/qemu/patches: patch-target_m68k_op-helper.c

Log Message:
Two emulation patches:
- hw/mc146818rtc.c -- replace previous patch with the one that fixes the
  same issue but is more correct by Philippe Mathieu-Daudé (also
  being upstreamed).
- m68k/op_helper.c -- In the DIVS.L helper, special case INT_MIN / -1,
  which traps on some hosts and crashes Qemu (Qemu issue #2078).

Bump PKGREVISION to 4.


To generate a diff of this commit:
cvs rdiff -u -r1.421 -r1.422 pkgsrc/emulators/qemu/Makefile
cvs rdiff -u -r1.258 -r1.259 pkgsrc/emulators/qemu/distinfo
cvs rdiff -u -r1.1 -r1.2 \
    pkgsrc/emulators/qemu/patches/patch-hw_rtc_mc146818rtc.c
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/emulators/qemu/patches/patch-target_m68k_op-helper.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/emulators/qemu/Makefile
diff -u pkgsrc/emulators/qemu/Makefile:1.421 pkgsrc/emulators/qemu/Makefile:1.422
--- pkgsrc/emulators/qemu/Makefile:1.421        Sun Nov 15 19:37:06 2026
+++ pkgsrc/emulators/qemu/Makefile      Fri Nov 20 16:43:04 2026
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.421 2026/11/15 19:37:06 wiz Exp $
+# $NetBSD: Makefile,v 1.422 2026/11/20 16:43:04 thorpej Exp $
 
-PKGREVISION= 3
+PKGREVISION= 4
 .include "../../emulators/qemu/Makefile.common"
 
 CATEGORIES=    emulators

Index: pkgsrc/emulators/qemu/distinfo
diff -u pkgsrc/emulators/qemu/distinfo:1.258 pkgsrc/emulators/qemu/distinfo:1.259
--- pkgsrc/emulators/qemu/distinfo:1.258        Thu Oct 29 07:07:18 2026
+++ pkgsrc/emulators/qemu/distinfo      Fri Nov 20 16:43:04 2026
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.258 2026/10/29 07:07:18 adam Exp $
+$NetBSD: distinfo,v 1.259 2026/11/20 16:43:04 thorpej Exp $
 
 BLAKE2s (palcode-clipper-qemu-5.2.0nb8) = d388c896a80c1cc3d4785c8434d6688bbcfd54c28f7252ce550ab162a0bba321
 SHA512 (palcode-clipper-qemu-5.2.0nb8) = 33695d6001d86a19793a92d5e31775607c4dfc9ab9eea019ea6c4d543a2e11e8c07f83cca4934811a13ef829b528737ea37d9d2aaf66cba6f2746d44d2aa0b43
@@ -16,7 +16,7 @@ SHA1 (patch-hw_9pfs_9p.h) = 4e2749619d21
 SHA1 (patch-hw_9pfs_codir.c) = c065762ee13fdeaef063632f56d9d0ead6b68f61
 SHA1 (patch-hw_9pfs_meson.build) = 0fb98920bd0678c00c035dc1178edab526ecbc19
 SHA1 (patch-hw_net_xilinx__axienet.c) = ebcd2676d64ce6f31e4a8c976d4fdf530ad5e8b7
-SHA1 (patch-hw_rtc_mc146818rtc.c) = cc7a3b28010966b65b7a16db756226ac2669f310
+SHA1 (patch-hw_rtc_mc146818rtc.c) = 0b923e516de17eb9887c17c679a4b0cb656a046f
 SHA1 (patch-hw_scsi_scsi-disk.c) = fdbf2f962a6dcb1a115a7f8a5b8790ff9295fb33
 SHA1 (patch-hw_usb_dev-mtp.c) = f148a3ad6d72eb29f85684316af5fb219ddaeb71
 SHA1 (patch-meson.build) = 2280e0b23b7a1e5e1c1208b9b5857a56676e58b4
@@ -26,5 +26,6 @@ SHA1 (patch-target_arm_tcg_translate-sve
 SHA1 (patch-target_i386_cpu.c) = 46a37ffc8ece4db52e8239b32dde37403ad568bb
 SHA1 (patch-target_i386_nvmm_nvmm-all.c) = 405a3b7ee1c719704bd9517c9dea53f47380c1ab
 SHA1 (patch-target_m68k_helper.c) = eb559e93dfaacf1ce546e89d31243c3933636b16
+SHA1 (patch-target_m68k_op-helper.c) = 7b37e1fefdb972397209fa41ca5db61557444e83
 SHA1 (patch-util_coroutine-ucontext.c) = 02cdf634e64f7e71029047b93747f192df715e6a
 SHA1 (patch-util_osdep.c) = 94144b7fc3c472ae7b21c3daa4fae62da3288c7d

Index: pkgsrc/emulators/qemu/patches/patch-hw_rtc_mc146818rtc.c
diff -u pkgsrc/emulators/qemu/patches/patch-hw_rtc_mc146818rtc.c:1.1 pkgsrc/emulators/qemu/patches/patch-hw_rtc_mc146818rtc.c:1.2
--- pkgsrc/emulators/qemu/patches/patch-hw_rtc_mc146818rtc.c:1.1        Sun Oct  4 20:39:25 2020
+++ pkgsrc/emulators/qemu/patches/patch-hw_rtc_mc146818rtc.c    Fri Nov 20 16:43:05 2026
@@ -1,32 +1,62 @@
-$NetBSD: patch-hw_rtc_mc146818rtc.c,v 1.1 2020/10/04 20:39:25 thorpej Exp $
+$NetBSD: patch-hw_rtc_mc146818rtc.c,v 1.2 2026/11/20 16:43:05 thorpej Exp $
 
 Ensure the periodic timer is started as soon as the device is realized,
 and follow the real hardware's lead of updating the PF bit in REG_C even
 if it's not going to result in raising an interrupt.
 
---- hw/rtc/mc146818rtc.c.orig  2020-10-01 00:56:55.574093880 +0000
-+++ hw/rtc/mc146818rtc.c       2020-10-01 00:58:40.326479896 +0000
-@@ -155,9 +155,15 @@ static uint32_t rtc_periodic_clock_ticks
+--- hw/rtc/mc146818rtc.c.orig  2026-10-28 19:57:39.000000000 +0000
++++ hw/rtc/mc146818rtc.c       2026-11-20 13:49:44.592550959 +0000
+@@ -132,10 +132,6 @@ static uint32_t rtc_periodic_clock_ticks
  {
      int period_code;
  
-+#if 0
-+    /*
-+     * Real hardware sets the PF bit rergardless if it actually
-+     * raises an interrupt.
-+     */
-     if (!(s->cmos_data[RTC_REG_B] & REG_B_PIE)) {
-         return 0;
-      }
-+#endif
- 
+-    if (!(s->cmos_data[RTC_REG_B] & REG_B_PIE)) {
+-        return 0;
+-     }
+-
      period_code = s->cmos_data[RTC_REG_A] & 0x0f;
  
-@@ -944,6 +950,7 @@ static void rtc_realizefn(DeviceState *d
+     return periodic_period_to_clock(period_code);
+@@ -160,6 +156,12 @@ static void periodic_timer_update(MC1468
+         return;
+     }
+ 
++    if (!(s->cmos_data[RTC_REG_B] & REG_B_PIE) &&
++        (s->cmos_data[RTC_REG_C] & REG_C_PF)) {
++        timer_del(s->periodic_timer);
++        return;
++    }
++
+     /* compute 32 khz clock */
+     cur_clock =
+         muldiv64(current_time, RTC_CLOCK_RATE, NANOSECONDS_PER_SECOND);
+@@ -192,7 +194,8 @@ static void periodic_timer_update(MC1468
+      *    to a shorter period, scale up the missing ticks since the
+      *    OS handler will treat past delayed ticks as shorter.
+      */
+-    if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW) {
++    if (s->lost_tick_policy == LOST_TICK_POLICY_SLEW &&
++        (s->cmos_data[RTC_REG_B] & REG_B_PIE)) {
+         uint32_t old_irq_coalesced = s->irq_coalesced;
+ 
+         lost_clock += old_irq_coalesced * old_period;
+@@ -239,6 +242,8 @@ static void rtc_periodic_timer(void *opa
+             }
+         } else
+             qemu_irq_raise(s->irq);
++    } else {
++        timer_del(s->periodic_timer);
      }
+ }
  
-     s->periodic_timer = timer_new_ns(rtc_clock, rtc_periodic_timer, s);
-+    periodic_timer_update(s, qemu_clock_get_ns(rtc_clock), 0, true);
-     s->update_timer = timer_new_ns(rtc_clock, rtc_update_timer, s);
-     check_update_timer(s);
+@@ -700,6 +705,10 @@ static uint64_t cmos_ioport_read(void *o
+             if (ret & (REG_C_UF | REG_C_AF)) {
+                 check_update_timer(s);
+             }
++          if ((ret & REG_C_PF) && !(s->cmos_data[RTC_REG_B] & REG_B_PIE)) {
++                periodic_timer_update(s, qemu_clock_get_ns(rtc_clock),
++                                      s->period, false);
++            }
  
+             if(s->irq_coalesced &&
+                     (s->cmos_data[RTC_REG_B] & REG_B_PIE) &&

Added files:

Index: pkgsrc/emulators/qemu/patches/patch-target_m68k_op-helper.c
diff -u /dev/null pkgsrc/emulators/qemu/patches/patch-target_m68k_op-helper.c:1.1
--- /dev/null   Fri Nov 20 16:43:05 2026
+++ pkgsrc/emulators/qemu/patches/patch-target_m68k_op-helper.c Fri Nov 20 16:43:05 2026
@@ -0,0 +1,37 @@
+$NetBSD: patch-target_m68k_op-helper.c,v 1.1 2026/11/20 16:43:05 thorpej Exp $
+
+Patch for Qemu issue #2078.
+
+* Avoid integer division underflow that can cause arithmetic exception
+  on the host system and crash Qemu.
+
+--- target/m68k/op_helper.c.orig       2026-10-28 19:57:39.000000000 +0000
++++ target/m68k/op_helper.c    2026-11-20 16:33:08.490830343 +0000
+@@ -679,12 +679,22 @@ void HELPER(divsl)(CPUM68KState *env, in
+     if (den == 0) {
+         raise_exception_format2(env, EXCP_DIV0, ilen, GETPC());
+     }
+-    quot = num / den;
+-    rem = num % den;
++    if (unlikely(num == INT32_MIN) && den == -1) {
++        env->cc_v = -1;
++        /*
++         * real 68040 keeps N and unset Z on overflow,
++         * whereas documentation says "undefined"
++         */
++        env->cc_z = 1;
++      return;
++    } else {
++        quot = num / den;
++        rem = num % den;
+ 
+-    env->cc_z = quot;
+-    env->cc_n = quot;
+-    env->cc_v = 0;
++        env->cc_z = quot;
++        env->cc_n = quot;
++        env->cc_v = 0;
++    }
+ 
+     if (m68k_feature(env, M68K_FEATURE_CF_ISA_A)) {
+         if (numr == regr) {



Home | Main Index | Thread Index | Old Index