Re: kernel oops loading i915 after "x86/asm: Pin sensitive CR4 bits" (873d50d58)

2019-07-10 Thread Dmitry V. Levin
Hi,

On Wed, Jul 10, 2019 at 01:44:17PM +0800, Xi Ruoyao wrote:
> Hello,
> 
> When I try to build and run the latest mainline kernel, it Oops loading i915
> module:
> 
> BUG: unable to handle page fault for address: 9edc1598
> #PF: supervisor write access in kernel mode
> #PF: error_code(0x0003) - permissions violation
> PGD 1a20c067 P4D 1a20c067 PUD 1a20d063 PMD 800019e000e1 
> Oops: 0003 [#1] SMP PTI
> 
> The complete log is attached.
> 
> Bisection tells "x86/asm: Pin sensitive CR4 bits" (873d50d58) is the first 
> "bad"
> commit.  I can revert it and also "x86/asm: Pin sensitive CR0 bits" 
> (8dbec27a2)
> to make the kernel "seems to" work.
> 
> I'm not a kernel expert so I can't tell if there is a bug in Kees' patch, or 
> his
> patch exploits a bug in i915 or module loader.

This seems to be a kernel bug introduced after v5.2, see
https://lore.kernel.org/lkml/CAHk-=wjh+h_-fd-gJz=wor42znmqq46qnb90jyfzqmklslf...@mail.gmail.com/


-- 
ldv


[PATCH 2/2] uapi: fix more linux/kfd_ioctl.h userspace compilation errors

2018-11-02 Thread Dmitry V. Levin
Consistently use types provided by  via 
to fix struct kfd_ioctl_get_queue_wave_state_args userspace compilation errors.

Fixes: 5df099e8bc83f ("drm/amdkfd: Add wavefront context save state retrieval 
ioctl")
Signed-off-by: Dmitry V. Levin 
---
 include/uapi/linux/kfd_ioctl.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index dae897f38e59..b01eb502d49c 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -83,11 +83,11 @@ struct kfd_ioctl_set_cu_mask_args {
 };
 
 struct kfd_ioctl_get_queue_wave_state_args {
-   uint64_t ctl_stack_address; /* to KFD */
-   uint32_t ctl_stack_used_size;   /* from KFD */
-   uint32_t save_area_used_size;   /* from KFD */
-   uint32_t queue_id;  /* to KFD */
-   uint32_t pad;
+   __u64 ctl_stack_address;/* to KFD */
+   __u32 ctl_stack_used_size;  /* from KFD */
+   __u32 save_area_used_size;  /* from KFD */
+   __u32 queue_id; /* to KFD */
+   __u32 pad;
 };
 
 /* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */
-- 
ldv
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/2] uapi: fix linux/kfd_ioctl.h userspace compilation errors

2018-11-02 Thread Dmitry V. Levin
Consistently use types provided by  via 
to fix the following linux/kfd_ioctl.h userspace compilation errors:

/usr/include/linux/kfd_ioctl.h:250:2: error: unknown type name 'uint32_t'
  uint32_t reset_type;
/usr/include/linux/kfd_ioctl.h:251:2: error: unknown type name 'uint32_t'
  uint32_t reset_cause;
/usr/include/linux/kfd_ioctl.h:252:2: error: unknown type name 'uint32_t'
  uint32_t memory_lost;
/usr/include/linux/kfd_ioctl.h:253:2: error: unknown type name 'uint32_t'
  uint32_t gpu_id;

Fixes: 0c119abad7f0d ("drm/amd: Add kfd ioctl defines for hw_exception event")
Cc:  # v4.19
Signed-off-by: Dmitry V. Levin 
---
 include/uapi/linux/kfd_ioctl.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index f5ff8a76e208..dae897f38e59 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -255,10 +255,10 @@ struct kfd_hsa_memory_exception_data {
 
 /* hw exception data */
 struct kfd_hsa_hw_exception_data {
-   uint32_t reset_type;
-   uint32_t reset_cause;
-   uint32_t memory_lost;
-   uint32_t gpu_id;
+   __u32 reset_type;
+   __u32 reset_cause;
+   __u32 memory_lost;
+   __u32 gpu_id;
 };
 
 /* Event data */
-- 
ldv
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] uapi: fix linux/kfd_ioctl.h userspace compilation errors

2018-04-05 Thread Dmitry V. Levin
Consistently use types provided by  via 
to fix the following linux/kfd_ioctl.h userspace compilation errors:

/usr/include/linux/kfd_ioctl.h:266:2: error: unknown type name 'uint64_t'
  uint64_t tba_addr;  /* to KFD */
/usr/include/linux/kfd_ioctl.h:267:2: error: unknown type name 'uint64_t'
  uint64_t tma_addr;  /* to KFD */
/usr/include/linux/kfd_ioctl.h:268:2: error: unknown type name 'uint32_t'
  uint32_t gpu_id;  /* to KFD */
/usr/include/linux/kfd_ioctl.h:269:2: error: unknown type name 'uint32_t'
  uint32_t pad;

Fixes: d7b9bd2248d79 ("drm/amdkfd: Add support for user-mode trap handlers")
Cc: <sta...@vger.kernel.org> # v4.16
Signed-off-by: Dmitry V. Levin <l...@altlinux.org>
---
 include/uapi/linux/kfd_ioctl.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index f4cab5b3ba9a..111d73ba2d96 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -263,10 +263,10 @@ struct kfd_ioctl_get_tile_config_args {
 };
 
 struct kfd_ioctl_set_trap_handler_args {
-   uint64_t tba_addr;  /* to KFD */
-   uint64_t tma_addr;  /* to KFD */
-   uint32_t gpu_id;/* to KFD */
-   uint32_t pad;
+   __u64 tba_addr; /* to KFD */
+   __u64 tma_addr; /* to KFD */
+   __u32 gpu_id;   /* to KFD */
+   __u32 pad;
 };
 
 #define AMDKFD_IOCTL_BASE 'K'
-- 
ldv
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] uapi: fix linux/kfd_ioctl.h userspace compilation errors

2017-11-13 Thread Dmitry V. Levin
Consistently use types provided by  via 
to fix the following linux/kfd_ioctl.h userspace compilation errors:

/usr/include/linux/kfd_ioctl.h:236:2: error: unknown type name 'uint64_t'
  uint64_t va_addr; /* to KFD */
/usr/include/linux/kfd_ioctl.h:237:2: error: unknown type name 'uint32_t'
  uint32_t gpu_id; /* to KFD */
/usr/include/linux/kfd_ioctl.h:238:2: error: unknown type name 'uint32_t'
  uint32_t pad;
/usr/include/linux/kfd_ioctl.h:243:2: error: unknown type name 'uint64_t'
  uint64_t tile_config_ptr;
/usr/include/linux/kfd_ioctl.h:245:2: error: unknown type name 'uint64_t'
  uint64_t macro_tile_config_ptr;
/usr/include/linux/kfd_ioctl.h:249:2: error: unknown type name 'uint32_t'
  uint32_t num_tile_configs;
/usr/include/linux/kfd_ioctl.h:253:2: error: unknown type name 'uint32_t'
  uint32_t num_macro_tile_configs;
/usr/include/linux/kfd_ioctl.h:255:2: error: unknown type name 'uint32_t'
  uint32_t gpu_id;  /* to KFD */
/usr/include/linux/kfd_ioctl.h:256:2: error: unknown type name 'uint32_t'
  uint32_t gb_addr_config; /* from KFD */
/usr/include/linux/kfd_ioctl.h:257:2: error: unknown type name 'uint32_t'
  uint32_t num_banks;  /* from KFD */
/usr/include/linux/kfd_ioctl.h:258:2: error: unknown type name 'uint32_t'
  uint32_t num_ranks;  /* from KFD */

Fixes: 6a1c9510694fe ("drm/amdkfd: Adding new IOCTL for scratch memory v2")
Fixes: 5d71dbc3a5886 ("drm/amdkfd: Implement image tiling mode support v2")
Signed-off-by: Dmitry V. Levin <l...@altlinux.org>
---
 include/uapi/linux/kfd_ioctl.h | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index 26283fefdf5f..f7015aa12347 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -233,29 +233,29 @@ struct kfd_ioctl_wait_events_args {
 };
 
 struct kfd_ioctl_set_scratch_backing_va_args {
-   uint64_t va_addr;   /* to KFD */
-   uint32_t gpu_id;/* to KFD */
-   uint32_t pad;
+   __u64 va_addr;  /* to KFD */
+   __u32 gpu_id;   /* to KFD */
+   __u32 pad;
 };
 
 struct kfd_ioctl_get_tile_config_args {
/* to KFD: pointer to tile array */
-   uint64_t tile_config_ptr;
+   __u64 tile_config_ptr;
/* to KFD: pointer to macro tile array */
-   uint64_t macro_tile_config_ptr;
+   __u64 macro_tile_config_ptr;
/* to KFD: array size allocated by user mode
 * from KFD: array size filled by kernel
 */
-   uint32_t num_tile_configs;
+   __u32 num_tile_configs;
/* to KFD: array size allocated by user mode
 * from KFD: array size filled by kernel
 */
-   uint32_t num_macro_tile_configs;
+   __u32 num_macro_tile_configs;
 
-   uint32_t gpu_id;/* to KFD */
-   uint32_t gb_addr_config;/* from KFD */
-   uint32_t num_banks; /* from KFD */
-   uint32_t num_ranks; /* from KFD */
+   __u32 gpu_id;   /* to KFD */
+   __u32 gb_addr_config;   /* from KFD */
+   __u32 num_banks;/* from KFD */
+   __u32 num_ranks;/* from KFD */
/* struct size can be extended later if needed
 * without breaking ABI compatibility
 */
-- 
ldv
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] uapi: fix drm/omap_drm.h userspace compilation errors

2017-02-25 Thread Dmitry V. Levin
Consistently use types from linux/types.h like in other uapi drm/*_drm.h
header files to fix the following drm/omap_drm.h userspace compilation
errors:

/usr/include/drm/omap_drm.h:36:2: error: unknown type name 'uint64_t'
  uint64_t param;   /* in */
/usr/include/drm/omap_drm.h:37:2: error: unknown type name 'uint64_t'
  uint64_t value;   /* in (set_param), out (get_param) */
/usr/include/drm/omap_drm.h:56:2: error: unknown type name 'uint32_t'
  uint32_t bytes;  /* (for non-tiled formats) */
/usr/include/drm/omap_drm.h:58:3: error: unknown type name 'uint16_t'
   uint16_t width;
/usr/include/drm/omap_drm.h:59:3: error: unknown type name 'uint16_t'
   uint16_t height;
/usr/include/drm/omap_drm.h:65:2: error: unknown type name 'uint32_t'
  uint32_t flags;   /* in */
/usr/include/drm/omap_drm.h:66:2: error: unknown type name 'uint32_t'
  uint32_t handle;  /* out */
/usr/include/drm/omap_drm.h:67:2: error: unknown type name 'uint32_t'
  uint32_t __pad;
/usr/include/drm/omap_drm.h:77:2: error: unknown type name 'uint32_t'
  uint32_t handle;  /* buffer handle (in) */
/usr/include/drm/omap_drm.h:78:2: error: unknown type name 'uint32_t'
  uint32_t op;   /* mask of omap_gem_op (in) */
/usr/include/drm/omap_drm.h:82:2: error: unknown type name 'uint32_t'
  uint32_t handle;  /* buffer handle (in) */
/usr/include/drm/omap_drm.h:83:2: error: unknown type name 'uint32_t'
  uint32_t op;   /* mask of omap_gem_op (in) */
/usr/include/drm/omap_drm.h:88:2: error: unknown type name 'uint32_t'
  uint32_t nregions;
/usr/include/drm/omap_drm.h:89:2: error: unknown type name 'uint32_t'
  uint32_t __pad;
/usr/include/drm/omap_drm.h:93:2: error: unknown type name 'uint32_t'
  uint32_t handle;  /* buffer handle (in) */
/usr/include/drm/omap_drm.h:94:2: error: unknown type name 'uint32_t'
  uint32_t pad;
/usr/include/drm/omap_drm.h:95:2: error: unknown type name 'uint64_t'
  uint64_t offset;  /* mmap offset (out) */
/usr/include/drm/omap_drm.h:102:2: error: unknown type name 'uint32_t'
  uint32_t size;   /* virtual size for mmap'ing (out) */
/usr/include/drm/omap_drm.h:103:2: error: unknown type name 'uint32_t'
  uint32_t __pad;

Fixes: ef6503e89194 ("drm: Kbuild: add omap_drm.h to the installed headers")
Signed-off-by: Dmitry V. Levin <l...@altlinux.org>
---
 include/uapi/drm/omap_drm.h | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h
index 407cb55..7fb9786 100644
--- a/include/uapi/drm/omap_drm.h
+++ b/include/uapi/drm/omap_drm.h
@@ -33,8 +33,8 @@ extern "C" {
 #define OMAP_PARAM_CHIPSET_ID  1   /* ie. 0x3430, 0x4430, etc */
 
 struct drm_omap_param {
-   uint64_t param; /* in */
-   uint64_t value; /* in (set_param), out (get_param) */
+   __u64 param;/* in */
+   __u64 value;/* in (set_param), out (get_param) */
 };
 
 #define OMAP_BO_SCANOUT0x0001  /* scanout capable 
(phys contiguous) */
@@ -53,18 +53,18 @@ struct drm_omap_param {
 #define OMAP_BO_TILED  (OMAP_BO_TILED_8 | OMAP_BO_TILED_16 | 
OMAP_BO_TILED_32)
 
 union omap_gem_size {
-   uint32_t bytes; /* (for non-tiled formats) */
+   __u32 bytes;/* (for non-tiled formats) */
struct {
-   uint16_t width;
-   uint16_t height;
+   __u16 width;
+   __u16 height;
} tiled;/* (for tiled formats) */
 };
 
 struct drm_omap_gem_new {
union omap_gem_size size;   /* in */
-   uint32_t flags; /* in */
-   uint32_t handle;/* out */
-   uint32_t __pad;
+   __u32 flags;/* in */
+   __u32 handle;   /* out */
+   __u32 __pad;
 };
 
 /* mask of operations: */
@@ -74,33 +74,33 @@ enum omap_gem_op {
 };
 
 struct drm_omap_gem_cpu_prep {
-   uint32_t handle;/* buffer handle (in) */
-   uint32_t op;/* mask of omap_gem_op (in) */
+   __u32 handle;   /* buffer handle (in) */
+   __u32 op;   /* mask of omap_gem_op (in) */
 };
 
 struct drm_omap_gem_cpu_fini {
-   uint32_t handle;/* buffer handle (in) */
-   uint32_t op;/* mask of omap_gem_op (in) */
+   __u32 handle;   /* buffer handle (in) */
+   __u32 op;   /* mask of omap_gem_op (in) */
/* TODO maybe here we pass down info about what regions are touched
 * by sw so we can be clever about cache ops?  For now a placeholder,
 * set to zero and we just do full buffer flush..
 */
-   uint32_t nregions;
-   uint32_t __pad;
+   __u32 nregions;
+   __u32 __pad;
 };
 
 struct drm_omap_gem_info {
-   uint32_t handle;/* buffer handle (i