From 7200282c76e548997e696eb1e9df483d426c4d70 Mon Sep 17 00:00:00 2001 From: wzx Date: Wed, 26 Oct 2022 12:44:31 +0800 Subject: [PATCH] Add sw64 architecture Signed-off-by: wzx (cherry picked from commit bf5089f3295cb1589eb89ed044cd3aa374e434ad) --- xorg-server-1.20.11-sw.patch | 672 +++++++++++++++++++++++++++++++++++ xorg-x11-server.spec | 12 +- 2 files changed, 680 insertions(+), 4 deletions(-) create mode 100755 xorg-server-1.20.11-sw.patch diff --git a/xorg-server-1.20.11-sw.patch b/xorg-server-1.20.11-sw.patch new file mode 100755 index 0000000..296621c --- /dev/null +++ b/xorg-server-1.20.11-sw.patch @@ -0,0 +1,672 @@ +From c99b7ba27942230458a127e9925d073ac75466af Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Fri, 26 Aug 2022 11:09:12 +0000 +Subject: [PATCH] sw + +--- + configure | 24 +++ + configure.ac | 9 + + hw/xfree86/common/compiler.h | 24 ++- + hw/xfree86/dri/dri.c | 2 +- + hw/xfree86/dri/sarea.h | 2 +- + hw/xfree86/os-support/bsd/Makefile.am | 6 + + hw/xfree86/os-support/bsd/Makefile.in | 24 ++- + hw/xfree86/os-support/bsd/sw_64_video.c | 234 ++++++++++++++++++++++++ + hw/xfree86/os-support/linux/lnx_video.c | 4 +- + hw/xfree86/os-support/meson.build | 2 + + hw/xfree86/os-support/misc/SlowBcopy.c | 4 +- + include/do-not-use-config.h.in | 3 + + include/xorg-config.h.in | 3 + + include/xorg-config.h.meson.in | 3 + + xkb/xkbInit.c | 2 +- + 15 files changed, 322 insertions(+), 24 deletions(-) + create mode 100644 hw/xfree86/os-support/bsd/sw_64_video.c + +diff --git a/configure b/configure +index 7e53cbd..009e48a 100755 +--- a/configure ++++ b/configure +@@ -1055,6 +1055,8 @@ I386_VIDEO_FALSE + I386_VIDEO_TRUE + ARM_VIDEO_FALSE + ARM_VIDEO_TRUE ++SW_64_VIDEO_FALSE ++SW_64_VIDEO_TRUE + ALPHA_VIDEO_FALSE + ALPHA_VIDEO_TRUE + GLX_ARCH_DEFINES +@@ -23208,6 +23210,16 @@ DEFAULT_INT10="x86emu" + + + case $host_cpu in ++ sw_64*) ++ SW_64_VIDEO=yes ++ case $host_os in ++ *freebsd*) SYS_LIBS=-lio ;; ++ *netbsd*) ++$as_echo "#define USE_SW_64_PIO 1" >>confdefs.h ++ ;; ++ esac ++ GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee" ++ ;; + alpha*) + ALPHA_VIDEO=yes + case $host_os in +@@ -23289,6 +23301,14 @@ else + ALPHA_VIDEO_FALSE= + fi + ++ if test "x$SW_64_VIDEO" = xyes; then ++ SW_64_VIDEO_TRUE= ++ SW_64_VIDEO_FALSE='#' ++else ++ SW_64_VIDEO_TRUE='#' ++ SW_64_VIDEO_FALSE= ++fi ++ + if test "x$ARM_VIDEO" = xyes; then + ARM_VIDEO_TRUE= + ARM_VIDEO_FALSE='#' +@@ -32898,6 +32918,10 @@ if test -z "${BSD_KQUEUE_APM_TRUE}" && test -z "${BSD_KQUEUE_APM_FALSE}"; then + as_fn_error $? "conditional \"BSD_KQUEUE_APM\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 + fi ++if test -z "${SW_64_VIDEO_TRUE}" && test -z "${SW_64_VIDEO_FALSE}"; then ++ as_fn_error $? "conditional \"SW_64_VIDEO\" was never defined. ++Usually this means the macro was only invoked conditionally." "$LINENO" 5 ++fi + if test -z "${ALPHA_VIDEO_TRUE}" && test -z "${ALPHA_VIDEO_FALSE}"; then + as_fn_error $? "conditional \"ALPHA_VIDEO\" was never defined. + Usually this means the macro was only invoked conditionally." "$LINENO" 5 +diff --git a/configure.ac b/configure.ac +index 7ba6d05..3a8b759 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -258,6 +258,14 @@ DEFAULT_INT10="x86emu" + dnl Override defaults as needed for specific platforms: + + case $host_cpu in ++ sw_64*) ++ SW_64_VIDEO=yes ++ case $host_os in ++ *freebsd*) SYS_LIBS=-lio ;; ++ *netbsd*) AC_DEFINE(USE_SW_64_PIO, 1, [NetBSD PIO sw_64 IO]) ;; ++ esac ++ GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee" ++ ;; + alpha*) + ALPHA_VIDEO=yes + case $host_os in +@@ -319,6 +327,7 @@ AC_SUBST(GLX_ARCH_DEFINES) + + dnl BSD *_video.c selection + AM_CONDITIONAL(ALPHA_VIDEO, [test "x$ALPHA_VIDEO" = xyes]) ++AM_CONDITIONAL(SW_64_VIDEO, [test "x$SW_64_VIDEO" = xyes]) + AM_CONDITIONAL(ARM_VIDEO, [test "x$ARM_VIDEO" = xyes]) + AM_CONDITIONAL(I386_VIDEO, [test "x$I386_VIDEO" = xyes]) + AM_CONDITIONAL(PPC_VIDEO, [test "x$PPC_VIDEO" = xyes]) +diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h +index 2b2008b..c416d65 100644 +--- a/hw/xfree86/common/compiler.h ++++ b/hw/xfree86/common/compiler.h +@@ -99,6 +99,7 @@ + #if !defined(__arm__) + #if !defined(__sparc__) && !defined(__arm32__) && !defined(__nds32__) \ + && !(defined(__alpha__) && defined(__linux__)) \ ++ && !(defined(__sw_64__) && defined(__linux__)) \ + && !(defined(__ia64__) && defined(__linux__)) \ + && !(defined(__mips64) && defined(__linux__)) \ + +@@ -109,7 +110,7 @@ extern _X_EXPORT unsigned int inb(unsigned short); + extern _X_EXPORT unsigned int inw(unsigned short); + extern _X_EXPORT unsigned int inl(unsigned short); + +-#else /* __sparc__, __arm32__, __alpha__, __nds32__ */ ++#else /* __sparc__, __arm32__, __alpha__, __sw_64__, __nds32__ */ + extern _X_EXPORT void outb(unsigned long, unsigned char); + extern _X_EXPORT void outw(unsigned long, unsigned short); + extern _X_EXPORT void outl(unsigned long, unsigned int); +@@ -129,7 +130,7 @@ extern _X_EXPORT void xf86WriteMmio16Le (void *, unsigned long, unsigned int); + extern _X_EXPORT void xf86WriteMmio32Be (void *, unsigned long, unsigned int); + extern _X_EXPORT void xf86WriteMmio32Le (void *, unsigned long, unsigned int); + #endif /* _SUNPRO_C */ +-#endif /* __sparc__, __arm32__, __alpha__, __nds32__ */ ++#endif /* __sparc__, __arm32__, __alpha__, __sw_64__, __nds32__ */ + #endif /* __arm__ */ + + #endif /* NO_INLINE || DO_PROTOTYPES */ +@@ -149,6 +150,11 @@ extern _X_EXPORT void xf86WriteMmio32Le (void *, unsigned long, unsigned int); + #define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory") + #endif + ++#elif defined __sw_64__ ++ ++#define mem_barrier() __asm__ __volatile__ ("memb" : : : "memory") ++#define write_mem_barrier() __asm__ __volatile__ ("memb" : : : "memory") ++ + #elif defined __alpha__ + + #define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory") +@@ -213,7 +219,7 @@ extern _X_EXPORT void xf86WriteMmio32Le (void *, unsigned long, unsigned int); + #endif + + #ifdef __GNUC__ +-#if defined(__alpha__) ++#if defined(__alpha__) || defined(__sw_64__) + + #ifdef __linux__ + /* for Linux on Alpha, we use the LIBC _inx/_outx routines */ +@@ -955,7 +961,7 @@ inl(unsigned PORT_SIZE port) + #define MMIO_IS_BE + #endif + +-#ifdef __alpha__ ++#if defined __alpha__ || defined __sw_64__ + static inline int + xf86ReadMmio8(void *Base, unsigned long Offset) + { +@@ -1068,7 +1074,7 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int); + xf86WriteMmio32(base, offset, (CARD32)(val)) + #endif + +-#else /* !__alpha__ && !__powerpc__ && !__sparc__ */ ++#else /* !__alpha__ && !__sw_64__ && !__powerpc__ && !__sparc__ */ + + #define MMIO_IN8(base, offset) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) +@@ -1083,19 +1089,19 @@ extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int); + #define MMIO_OUT32(base, offset, val) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val) + +-#endif /* __alpha__ */ ++#endif /* __alpha__, __sw_64__ */ + + /* + * With Intel, the version in os-support/misc/SlowBcopy.s is used. + * This avoids port I/O during the copy (which causes problems with + * some hardware). + */ +-#ifdef __alpha__ ++#if defined __alpha__ || defined __sw_64__ + #define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count) + #define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count) +-#else /* __alpha__ */ ++#else /* __alpha__, __sw_64__ */ + #define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count) + #define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count) +-#endif /* __alpha__ */ ++#endif /* __alpha__, __sw_64__ */ + + #endif /* _COMPILER_H */ +diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c +index 9f70759..091681e 100644 +--- a/hw/xfree86/dri/dri.c ++++ b/hw/xfree86/dri/dri.c +@@ -2012,7 +2012,7 @@ DRISpinLockTimeout(drmLock * lock, int val, unsigned long timeout /* in mS */ ) + { + int count = 10000; + +-#if !defined(__alpha__) && !defined(__powerpc__) ++#if !defined(__alpha__) && !defined(__powerpc__) && !defined(__sw_64__) + char ret; + #else + int ret; +diff --git a/hw/xfree86/dri/sarea.h b/hw/xfree86/dri/sarea.h +index 1bef242..cd7e416 100644 +--- a/hw/xfree86/dri/sarea.h ++++ b/hw/xfree86/dri/sarea.h +@@ -39,7 +39,7 @@ + #include "xf86drm.h" + + /* SAREA area needs to be at least a page */ +-#if defined(__alpha__) ++#if defined(__alpha__) || defined(__sw_64__) + #define SAREA_MAX 0x2000 + #elif defined(__ia64__) + #define SAREA_MAX 0x10000 /* 64kB */ +diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am +index 66ac838..38fe659 100644 +--- a/hw/xfree86/os-support/bsd/Makefile.am ++++ b/hw/xfree86/os-support/bsd/Makefile.am +@@ -29,6 +29,12 @@ ARCH_SOURCES = \ + alpha_video.c + endif + ++if SW_64_VIDEO ++# Cheat here and piggyback other sw_64 bits on SW_64_VIDEO. ++ARCH_SOURCES = \ ++ sw_64_video.c ++endif ++ + if ARM_VIDEO + ARCH_SOURCES = arm_video.c + endif +diff --git a/hw/xfree86/os-support/bsd/Makefile.in b/hw/xfree86/os-support/bsd/Makefile.in +index 21495a2..ba525eb 100644 +--- a/hw/xfree86/os-support/bsd/Makefile.in ++++ b/hw/xfree86/os-support/bsd/Makefile.in +@@ -113,19 +113,20 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) + libbsd_la_LIBADD = + am__libbsd_la_SOURCES_DIST = $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigio.c $(srcdir)/../shared/vidmem.c \ +- bsd_VTsw.c bsd_init.c bsd_bell.c alpha_video.c arm_video.c \ ++ bsd_VTsw.c bsd_init.c bsd_bell.c alpha_video.c sw_64_video.c arm_video.c \ + i386_video.c ppc_video.c sparc64_video.c \ + $(srcdir)/../shared/ioperm_noop.c \ + $(srcdir)/../shared/agp_noop.c $(srcdir)/../linux/lnx_agp.c \ + $(srcdir)/../shared/pm_noop.c $(srcdir)/bsd_apm.c \ + $(srcdir)/bsd_kqueue_apm.c $(srcdir)/../shared/kmod_noop.c \ + bsd_kmod.c +-@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@am__objects_1 = sparc64_video.lo \ +-@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@ ioperm_noop.lo +-@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_TRUE@am__objects_1 = ppc_video.lo +-@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_TRUE@am__objects_1 = i386_video.lo +-@ALPHA_VIDEO_FALSE@@ARM_VIDEO_TRUE@am__objects_1 = arm_video.lo +-@ALPHA_VIDEO_TRUE@am__objects_1 = alpha_video.lo ++@SW_64_VIDEO_FALSE@@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@am__objects_1 = sparc64_video.lo \ ++@SW_64_VIDEO_FALSE@@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@ ioperm_noop.lo ++@SW_64_VIDEO_FALSE@@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_TRUE@am__objects_1 = ppc_video.lo ++@SW_64_VIDEO_FALSE@@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_TRUE@am__objects_1 = i386_video.lo ++@SW_64_VIDEO_FALSE@@ALPHA_VIDEO_FALSE@@ARM_VIDEO_TRUE@am__objects_1 = arm_video.lo ++@SW_64_VIDEO_FALSE@@ALPHA_VIDEO_TRUE@am__objects_1 = alpha_video.lo ++@SW_64_VIDEO_TURE@am__objects_1 = sw_64_video.lo + @AGP_FALSE@am__objects_2 = agp_noop.lo + @AGP_TRUE@am__objects_2 = lnx_agp.lo + @BSD_APM_FALSE@@BSD_KQUEUE_APM_FALSE@am__objects_3 = pm_noop.lo +@@ -157,7 +158,7 @@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include + depcomp = $(SHELL) $(top_srcdir)/depcomp + am__maybe_remake_depfiles = depfiles + am__depfiles_remade = ./$(DEPDIR)/agp_noop.Plo \ +- ./$(DEPDIR)/alpha_video.Plo ./$(DEPDIR)/arm_video.Plo \ ++ ./$(DEPDIR)/alpha_video.Plo ./$(DEPDIR)/sw_64_video.Plo ./$(DEPDIR)/arm_video.Plo \ + ./$(DEPDIR)/bsd_VTsw.Plo ./$(DEPDIR)/bsd_apm.Plo \ + ./$(DEPDIR)/bsd_bell.Plo ./$(DEPDIR)/bsd_init.Plo \ + ./$(DEPDIR)/bsd_kmod.Plo ./$(DEPDIR)/bsd_kqueue_apm.Plo \ +@@ -587,6 +588,10 @@ noinst_LTLIBRARIES = libbsd.la + @ALPHA_VIDEO_TRUE@ARCH_SOURCES = \ + @ALPHA_VIDEO_TRUE@ alpha_video.c + ++# Cheat here and piggyback other sw_64 bits on SW_64_VIDEO. ++@SW_64_VIDEO_TRUE@ARCH_SOURCES = \ ++@SW_64_VIDEO_TRUE@ sw_64_video.c ++ + @ARM_VIDEO_TRUE@ARCH_SOURCES = arm_video.c + @I386_VIDEO_TRUE@ARCH_SOURCES = i386_video.c + @PPC_VIDEO_TRUE@ARCH_SOURCES = ppc_video.c +@@ -676,6 +681,7 @@ distclean-compile: + + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agp_noop.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha_video.Plo@am__quote@ # am--include-marker ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sw_64_video.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm_video.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_VTsw.Plo@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_apm.Plo@am__quote@ # am--include-marker +@@ -924,6 +930,7 @@ clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + distclean: distclean-am + -rm -f ./$(DEPDIR)/agp_noop.Plo + -rm -f ./$(DEPDIR)/alpha_video.Plo ++ -rm -f ./$(DEPDIR)/sw_64_video.Plo + -rm -f ./$(DEPDIR)/arm_video.Plo + -rm -f ./$(DEPDIR)/bsd_VTsw.Plo + -rm -f ./$(DEPDIR)/bsd_apm.Plo +@@ -988,6 +995,7 @@ installcheck-am: + maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/agp_noop.Plo + -rm -f ./$(DEPDIR)/alpha_video.Plo ++ -rm -f ./$(DEPDIR)/sw_64_video.Plo + -rm -f ./$(DEPDIR)/arm_video.Plo + -rm -f ./$(DEPDIR)/bsd_VTsw.Plo + -rm -f ./$(DEPDIR)/bsd_apm.Plo +diff --git a/hw/xfree86/os-support/bsd/sw_64_video.c b/hw/xfree86/os-support/bsd/sw_64_video.c +new file mode 100644 +index 0000000..7c42435 +--- /dev/null ++++ b/hw/xfree86/os-support/bsd/sw_64_video.c +@@ -0,0 +1,234 @@ ++/* ++ * Copyright 1992 by Rich Murphey ++ * Copyright 1993 by David Wexelblat ++ * ++ * Permission to use, copy, modify, distribute, and sell this software and its ++ * documentation for any purpose is hereby granted without fee, provided that ++ * the above copyright notice appear in all copies and that both that ++ * copyright notice and this permission notice appear in supporting ++ * documentation, and that the names of Rich Murphey and David Wexelblat ++ * not be used in advertising or publicity pertaining to distribution of ++ * the software without specific, written prior permission. Rich Murphey and ++ * David Wexelblat make no representations about the suitability of this ++ * software for any purpose. It is provided "as is" without express or ++ * implied warranty. ++ * ++ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO ++ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND ++ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR ++ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ++ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF ++ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN ++ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ * ++ */ ++ ++#ifdef HAVE_XORG_CONFIG_H ++#include ++#endif ++ ++#include ++#include "xf86.h" ++#include "xf86Priv.h" ++ ++#include ++#ifndef __NetBSD__ ++#include ++#endif ++ ++#include "xf86_OSlib.h" ++#include "xf86OSpriv.h" ++ ++#if defined(__NetBSD__) && !defined(MAP_FILE) ++#define MAP_FLAGS MAP_SHARED ++#else ++#define MAP_FLAGS (MAP_FILE | MAP_SHARED) ++#endif ++ ++#ifndef __NetBSD__ ++extern unsigned long dense_base(void); ++#else /* __NetBSD__ */ ++static struct sw_64_bus_window *abw; ++static int abw_count = -1; ++ ++static void ++init_abw(void) ++{ ++ if (abw_count < 0) { ++ abw_count = sw_64_bus_getwindows(SW_64_BUS_TYPE_PCI_MEM, &abw); ++ if (abw_count <= 0) ++ FatalError("init_abw: sw_64_bus_getwindows failed\n"); ++ } ++} ++ ++static unsigned long ++dense_base(void) ++{ ++ if (abw_count < 0) ++ init_abw(); ++ ++ /* XXX check abst_flags for ABST_DENSE just to be safe? */ ++ xf86Msg(X_INFO, "dense base = %#lx\n", abw[0].abw_abst.abst_sys_start); /* XXXX */ ++ return abw[0].abw_abst.abst_sys_start; ++} ++ ++#endif /* __NetBSD__ */ ++ ++#define BUS_BASE dense_base() ++ ++/***************************************************************************/ ++/* Video Memory Mapping section */ ++/***************************************************************************/ ++ ++#ifdef __OpenBSD__ ++#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ ++ "\tin /etc/sysctl.conf and reboot your machine\n" \ ++ "\trefer to xf86(4) for details" ++#endif ++ ++static int devMemFd = -1; ++ ++#ifdef HAS_APERTURE_DRV ++#define DEV_APERTURE "/dev/xf86" ++#endif ++ ++/* ++ * Check if /dev/mem can be mmap'd. If it can't print a warning when ++ * "warn" is TRUE. ++ */ ++static void ++checkDevMem(Bool warn) ++{ ++ static Bool devMemChecked = FALSE; ++ int fd; ++ void *base; ++ ++ if (devMemChecked) ++ return; ++ devMemChecked = TRUE; ++ ++#ifdef HAS_APERTURE_DRV ++ /* Try the aperture driver first */ ++ if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) { ++ /* Try to map a page at the VGA address */ ++ base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE, ++ MAP_FLAGS, fd, (off_t) 0xA0000 + BUS_BASE); ++ ++ if (base != MAP_FAILED) { ++ munmap((caddr_t) base, 4096); ++ devMemFd = fd; ++ xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", ++ DEV_APERTURE); ++ return; ++ } ++ else { ++ if (warn) { ++ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", ++ DEV_APERTURE, strerror(errno)); ++ } ++ } ++ } ++#endif ++ if ((fd = open(DEV_MEM, O_RDWR)) >= 0) { ++ /* Try to map a page at the VGA address */ ++ base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE, ++ MAP_FLAGS, fd, (off_t) 0xA0000 + BUS_BASE); ++ ++ if (base != MAP_FAILED) { ++ munmap((caddr_t) base, 4096); ++ devMemFd = fd; ++ return; ++ } ++ else { ++ if (warn) { ++ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", ++ DEV_MEM, strerror(errno)); ++ } ++ } ++ } ++ if (warn) { ++#ifndef HAS_APERTURE_DRV ++ xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n", ++ DEV_MEM, strerror(errno)); ++#else ++#ifndef __OpenBSD__ ++ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" ++ "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno)); ++#else /* __OpenBSD__ */ ++ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" ++ "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno), ++ SYSCTL_MSG); ++#endif /* __OpenBSD__ */ ++#endif ++ xf86ErrorF("\tlinear framebuffer access unavailable\n"); ++ } ++ return; ++} ++ ++void ++xf86OSInitVidMem(VidMemInfoPtr pVidMem) ++{ ++ checkDevMem(TRUE); ++ ++ pVidMem->initialised = TRUE; ++} ++ ++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) ++ ++extern int ioperm(unsigned long from, unsigned long num, int on); ++ ++Bool ++xf86EnableIO() ++{ ++ if (!ioperm(0, 65536, TRUE)) ++ return TRUE; ++ return FALSE; ++} ++ ++void ++xf86DisableIO() ++{ ++ return; ++} ++ ++#endif /* __FreeBSD_kernel__ || __OpenBSD__ */ ++ ++#ifdef USE_SW_64_PIO ++ ++Bool ++xf86EnableIO() ++{ ++ sw_64_pci_io_enable(1); ++ return TRUE; ++} ++ ++void ++xf86DisableIO() ++{ ++ sw_64_pci_io_enable(0); ++} ++ ++#endif /* USE_SW_64_PIO */ ++ ++extern int readDense8(void *Base, register unsigned long Offset); ++extern int readDense16(void *Base, register unsigned long Offset); ++extern int readDense32(void *Base, register unsigned long Offset); ++extern void ++ writeDense8(int Value, void *Base, register unsigned long Offset); ++extern void ++ writeDense16(int Value, void *Base, register unsigned long Offset); ++extern void ++ writeDense32(int Value, void *Base, register unsigned long Offset); ++ ++void (*xf86WriteMmio8) (int Value, void *Base, unsigned long Offset) ++ = writeDense8; ++void (*xf86WriteMmio16) (int Value, void *Base, unsigned long Offset) ++ = writeDense16; ++void (*xf86WriteMmio32) (int Value, void *Base, unsigned long Offset) ++ = writeDense32; ++int (*xf86ReadMmio8) (void *Base, unsigned long Offset) ++ = readDense8; ++int (*xf86ReadMmio16) (void *Base, unsigned long Offset) ++ = readDense16; ++int (*xf86ReadMmio32) (void *Base, unsigned long Offset) ++ = readDense32; +diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c +index 04e4509..d4d7349 100644 +--- a/hw/xfree86/os-support/linux/lnx_video.c ++++ b/hw/xfree86/os-support/linux/lnx_video.c +@@ -111,7 +111,7 @@ hwDisableIO(void) + } + + #elif defined(__i386__) || defined(__x86_64__) || defined(__ia64__) || \ +- defined(__alpha__) ++ defined(__alpha__) || defined(__sw_64__) + + static Bool + hwEnableIO(void) +@@ -121,7 +121,7 @@ hwEnableIO(void) + strerror(errno)); + return FALSE; + } +-#if !defined(__alpha__) ++#if !defined(__alpha__) && !defined(__sw_64__) + /* XXX: this is actually not trapping anything because of iopl(3) + * above */ + ioperm(0x40, 4, 0); /* trap access to the timer chip */ +diff --git a/hw/xfree86/os-support/meson.build b/hw/xfree86/os-support/meson.build +index b6e5c97..0e2a127 100644 +--- a/hw/xfree86/os-support/meson.build ++++ b/hw/xfree86/os-support/meson.build +@@ -100,6 +100,8 @@ elif host_machine.system().endswith('bsd') + srcs_xorg_os_support += 'shared/ioperm_noop.c' + elif host_machine.cpu_family() == 'alpha' + srcs_xorg_os_support += 'bsd/alpha_video.c' ++ elif host_machine.cpu_family() == 'sw_64' ++ srcs_xorg_os_support += 'bsd/sw_64_video.c' + endif + + if host_machine.system() == 'freebsd' +diff --git a/hw/xfree86/os-support/misc/SlowBcopy.c b/hw/xfree86/os-support/misc/SlowBcopy.c +index 9d82c71..a7d9a7b 100644 +--- a/hw/xfree86/os-support/misc/SlowBcopy.c ++++ b/hw/xfree86/os-support/misc/SlowBcopy.c +@@ -1,5 +1,5 @@ + /******************************************************************************* +- for Alpha Linux ++ for Alpha/Sw_64 Linux + *******************************************************************************/ + + /* +@@ -55,7 +55,7 @@ xf86SlowBcopy(unsigned char *src, unsigned char *dst, int len) + *dst++ = *src++; + } + +-#ifdef __alpha__ ++#if defined __alpha__ || defined __sw_64__ + + #ifdef __linux__ + +diff --git a/include/do-not-use-config.h.in b/include/do-not-use-config.h.in +index f421c61..f440b84 100644 +--- a/include/do-not-use-config.h.in ++++ b/include/do-not-use-config.h.in +@@ -585,6 +585,9 @@ + /* Support UNIX socket connections */ + #undef UNIXCONN + ++/* NetBSD PIO sw_64 IO */ ++#undef USE_SW_64_PIO ++ + /* NetBSD PIO alpha IO */ + #undef USE_ALPHA_PIO + +diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in +index bf555eb..f40e1ca 100644 +--- a/include/xorg-config.h.in ++++ b/include/xorg-config.h.in +@@ -82,6 +82,9 @@ + /* Building vgahw module */ + #undef WITH_VGAHW + ++/* NetBSD PIO sw_64 IO */ ++#undef USE_SW_64_PIO ++ + /* NetBSD PIO alpha IO */ + #undef USE_ALPHA_PIO + +diff --git a/include/xorg-config.h.meson.in b/include/xorg-config.h.meson.in +index 1e4213f..27365f9 100644 +--- a/include/xorg-config.h.meson.in ++++ b/include/xorg-config.h.meson.in +@@ -79,6 +79,9 @@ + /* Building vgahw module */ + #mesondefine WITH_VGAHW + ++/* NetBSD PIO sw_64 IO */ ++#mesondefine USE_SW_64_PIO ++ + /* NetBSD PIO alpha IO */ + #mesondefine USE_ALPHA_PIO + +diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c +index 9e45b4b..c290fac 100644 +--- a/xkb/xkbInit.c ++++ b/xkb/xkbInit.c +@@ -53,7 +53,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. + + #define CREATE_ATOM(s) MakeAtom(s,sizeof(s)-1,1) + +-#if defined(__alpha) || defined(__alpha__) ++#if defined(__alpha) || defined(__alpha__) || defined(__sw_64) || defined(__sw_64__) + #define LED_COMPOSE 2 + #define LED_CAPS 3 + #define LED_SCROLL 4 +-- +2.33.0 + diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index 6614f21..8ebb19d 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -16,7 +16,7 @@ Name: xorg-x11-server Version: 1.20.11 -Release: 7 +Release: 8 Summary: X.Org X11 X server License: MIT and GPLv2 URL: https://www.x.org @@ -86,6 +86,7 @@ Patch6004: backport-rename-bool-to-boolean.patch Patch6005: backport-0001-CVE-2022-2319.patch Patch6006: backport-0002-CVE-2022-2319.patch Patch6007: backport-CVE-2022-2320.patch +Patch6008: xorg-server-1.20.11-sw.patch BuildRequires: audit-libs-devel autoconf automake bison dbus-devel flex git gcc BuildRequires: systemtap-sdt-devel libtool pkgconfig @@ -103,7 +104,7 @@ BuildRequires: libxshmfence-devel >= 1.1 pixman-devel >= 0.30.0 libdrm-devel >= BuildRequires: mesa-libGL-devel >= 9.2 libpciaccess-devel >= 0.13.1 BuildRequires: wayland-devel wayland-protocols-devel egl-wayland-devel -%ifarch aarch64 %{arm} x86_64 +%ifarch aarch64 %{arm} x86_64 sw_64 BuildRequires: libunwind-devel %endif @@ -256,7 +257,7 @@ export LDFLAGS="$RPM_LD_FLAGS -specs=/usr/lib/rpm/generic-hardened-ld" export CXXFLAGS="$RPM_OPT_FLAGS -specs=/usr/lib/rpm/generic-hardened-cc1" export CFLAGS="$RPM_OPT_FLAGS -specs=/usr/lib/rpm/generic-hardened-cc1" -%ifnarch %{ix86} x86_64 +%ifnarch %{ix86} x86_64 sw_64 %global no_int10 --disable-vbe --disable-int10-module %endif @@ -337,7 +338,7 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete { %delete_la -%ifnarch %{ix86} x86_64 +%ifnarch %{ix86} x86_64 sw_64 rm -f %{buildroot}/%{_libdir}/xorg/modules/lib{int10,vbe}.so %endif } @@ -429,6 +430,9 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %{_mandir}/man*/* %changelog +* Wed Oct 26 2022 wuzx - 1.20.11-8 +- Add sw64 architecture + * Wed Aug 03 2022 wangkerong - 1.20.11-7 - fix CVE-2022-2319,CVE-2022-2320 -- Gitee