for-linus-2023071101

-----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEoEVH9lhNrxiMPSyI7MXwXhnZSjYFAmStXZ8THGJlbnRpc3NA
 a2VybmVsLm9yZwAKCRDsxfBeGdlKNosgD/47F/dZe5bk9TskkZUaaO012+m9e1ab
 33p1GmFJgDFizO9ItwFr7q+DSfzAegrCogq4jztPBhDlmCHlAVc5UGSUmdmy1g9V
 WYMiL2SA6duwfGb82Ted+f26LGiqp98jAfguyXUIqskPXQITIZyPtGUv5ZswK+bh
 RNBWSoD8jJ6hN0+FpKxOAqwPI+JHqCDHffkWEC33KiyP/+aBoa6qtvjRqTJVU4bb
 y+hNBbkN6Wjj+gwlMWyTLnk6uHpcZCP+ye2SPHWTfFrr+SGFlhPNroosQijEycZU
 uMTULMhWZiNd6zkRGGNs0bontjMcuko1wr5fkiM2jCd2Gft7MjvPeV9kLChtR35j
 L2ybAJ8OfznhQ46GnqtaadybnF1M4CyWL4EWzpBQuqy+Xnp3GYLDUlqIJHtEMDjD
 /8QDh3j5P4bgUkjGFBkPOnHson3/NnNujIN3fMl8Wn/GfTky5SR9Usx7CH8cnyji
 JEoPfrLNwgRIVuInGxOxxpgq6YeK3MtRwR656PNacEcd6rMCEaegghVlLPX84zna
 IixAbfjshakaZ9s0ONzkDzjLyEW/aCzMGVgr0SZfvcHfGlfqRYMJqDAHoKof5YLj
 XdPcgM3rttzFffmb+/tR6c/UKXfFNrdITopS1+m59WG+Bowh/qXBShMbDTbNHVt5
 EOWUdKl/FnJhQA==
 =Syiu
 -----END PGP SIGNATURE-----

Merge tag 'for-linus-2023071101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid

Pull HID fixes from Benjamin Tissoires:

 - AMD SFH shift-out-of-bounds fix (Basavaraj Natikar)

 - avoid struct memcpy overrun warning in the hid-hyperv module (Arnd
   Bergmann)

 - a quick HID kselftests script fix for our CI to be happy (Benjamin
   Tissoires)

 - various fixes and additions of device IDs

* tag 'for-linus-2023071101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
  HID: amd_sfh: Fix for shift-out-of-bounds
  HID: amd_sfh: Rename the float32 variable
  HID: input: fix mapping for camera access keys
  HID: logitech-hidpp: Add wired USB id for Logitech G502 Lightspeed
  HID: nvidia-shield: Pack inner/related declarations in HOSTCMD reports
  HID: hyperv: avoid struct memcpy overrun warning
  selftests: hid: fix vmtests.sh not running make headers
This commit is contained in:
Linus Torvalds 2023-07-12 11:56:22 -07:00
commit 1d7546042f
6 changed files with 40 additions and 22 deletions

View File

@ -132,29 +132,45 @@ static void get_common_inputs(struct common_input_property *common, int report_i
common->event_type = HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM;
}
static int float_to_int(u32 float32)
static int float_to_int(u32 flt32_val)
{
int fraction, shift, mantissa, sign, exp, zeropre;
mantissa = float32 & GENMASK(22, 0);
sign = (float32 & BIT(31)) ? -1 : 1;
exp = (float32 & ~BIT(31)) >> 23;
mantissa = flt32_val & GENMASK(22, 0);
sign = (flt32_val & BIT(31)) ? -1 : 1;
exp = (flt32_val & ~BIT(31)) >> 23;
if (!exp && !mantissa)
return 0;
/*
* Calculate the exponent and fraction part of floating
* point representation.
*/
exp -= 127;
if (exp < 0) {
exp = -exp;
if (exp >= BITS_PER_TYPE(u32))
return 0;
zeropre = (((BIT(23) + mantissa) * 100) >> 23) >> exp;
return zeropre >= 50 ? sign : 0;
}
shift = 23 - exp;
float32 = BIT(exp) + (mantissa >> shift);
fraction = mantissa & GENMASK(shift - 1, 0);
if (abs(shift) >= BITS_PER_TYPE(u32))
return 0;
return (((fraction * 100) >> shift) >= 50) ? sign * (float32 + 1) : sign * float32;
if (shift < 0) {
shift = -shift;
flt32_val = BIT(exp) + (mantissa << shift);
shift = 0;
} else {
flt32_val = BIT(exp) + (mantissa >> shift);
}
fraction = (shift == 0) ? 0 : mantissa & GENMASK(shift - 1, 0);
return (((fraction * 100) >> shift) >= 50) ? sign * (flt32_val + 1) : sign * flt32_val;
}
static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,

View File

@ -258,19 +258,17 @@ static void mousevsc_on_receive(struct hv_device *device,
switch (hid_msg_hdr->type) {
case SYNTH_HID_PROTOCOL_RESPONSE:
len = struct_size(pipe_msg, data, pipe_msg->size);
/*
* While it will be impossible for us to protect against
* malicious/buggy hypervisor/host, add a check here to
* ensure we don't corrupt memory.
*/
if (struct_size(pipe_msg, data, pipe_msg->size)
> sizeof(struct mousevsc_prt_msg)) {
WARN_ON(1);
if (WARN_ON(len > sizeof(struct mousevsc_prt_msg)))
break;
}
memcpy(&input_dev->protocol_resp, pipe_msg,
struct_size(pipe_msg, data, pipe_msg->size));
memcpy(&input_dev->protocol_resp, pipe_msg, len);
complete(&input_dev->wait_event);
break;

View File

@ -1093,6 +1093,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x074: map_key_clear(KEY_BRIGHTNESS_MAX); break;
case 0x075: map_key_clear(KEY_BRIGHTNESS_AUTO); break;
case 0x076: map_key_clear(KEY_CAMERA_ACCESS_ENABLE); break;
case 0x077: map_key_clear(KEY_CAMERA_ACCESS_DISABLE); break;
case 0x078: map_key_clear(KEY_CAMERA_ACCESS_TOGGLE); break;
case 0x079: map_key_clear(KEY_KBDILLUMUP); break;
case 0x07a: map_key_clear(KEY_KBDILLUMDOWN); break;
case 0x07c: map_key_clear(KEY_KBDILLUMTOGGLE); break;
@ -1139,9 +1143,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
case 0x0cd: map_key_clear(KEY_PLAYPAUSE); break;
case 0x0cf: map_key_clear(KEY_VOICECOMMAND); break;
case 0x0d5: map_key_clear(KEY_CAMERA_ACCESS_ENABLE); break;
case 0x0d6: map_key_clear(KEY_CAMERA_ACCESS_DISABLE); break;
case 0x0d7: map_key_clear(KEY_CAMERA_ACCESS_TOGGLE); break;
case 0x0d8: map_key_clear(KEY_DICTATE); break;
case 0x0d9: map_key_clear(KEY_EMOJI_PICKER); break;

View File

@ -4598,6 +4598,8 @@ static const struct hid_device_id hidpp_devices[] = {
{ /* Logitech G403 Wireless Gaming Mouse over USB */
HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC082) },
{ /* Logitech G502 Lightspeed Wireless Gaming Mouse over USB */
HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC08D) },
{ /* Logitech G703 Gaming Mouse over USB */
HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC087) },
{ /* Logitech G703 Hero Gaming Mouse over USB */

View File

@ -63,12 +63,12 @@ static_assert(sizeof(enum thunderstrike_led_state) == 1);
struct thunderstrike_hostcmd_board_info {
__le16 revision;
__le16 serial[7];
};
} __packed;
struct thunderstrike_hostcmd_haptics {
u8 motor_left;
u8 motor_right;
};
} __packed;
struct thunderstrike_hostcmd_resp_report {
u8 report_id; /* THUNDERSTRIKE_HOSTCMD_RESP_REPORT_ID */
@ -81,7 +81,7 @@ struct thunderstrike_hostcmd_resp_report {
__le16 fw_version;
enum thunderstrike_led_state led_state;
u8 payload[30];
};
} __packed;
} __packed;
static_assert(sizeof(struct thunderstrike_hostcmd_resp_report) ==
THUNDERSTRIKE_HOSTCMD_REPORT_SIZE);
@ -92,15 +92,15 @@ struct thunderstrike_hostcmd_req_report {
u8 reserved_at_10;
union {
struct {
struct __packed {
u8 update;
enum thunderstrike_led_state state;
} led;
struct {
struct __packed {
u8 update;
struct thunderstrike_hostcmd_haptics motors;
} haptics;
};
} __packed;
u8 reserved_at_30[27];
} __packed;
static_assert(sizeof(struct thunderstrike_hostcmd_req_report) ==

View File

@ -79,6 +79,7 @@ recompile_kernel()
cd "${kernel_checkout}"
${make_command} olddefconfig
${make_command} headers
${make_command}
}