From patchwork Thu Feb 15 21:51:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 201764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp142849dyb; Thu, 15 Feb 2024 13:52:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCzukhyXd2epygCjXRdxNQhD+vAam849AtoN9jXAUAyU80otURvaHrSYsxLBvjNij8E4fpY5fM/kBpnZ1Pf6XcyYLcZA== X-Google-Smtp-Source: AGHT+IGf+A/Eb3RPUhb3AmmBYmoibAEWFdijLWUIoXNRsrddIXIq5nACd9gUNuro2jRE9onFWSbd X-Received: by 2002:a05:6a21:8cc4:b0:199:7d51:a942 with SMTP id ta4-20020a056a218cc400b001997d51a942mr4727607pzb.50.1708033927076; Thu, 15 Feb 2024 13:52:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708033927; cv=pass; d=google.com; s=arc-20160816; b=TR8TqGZQXbY/VEOTBpJQ86Gbb59E4Y480eK9VyL+rfxMPOj8ZSpzmN8ASp5RuexpVM lv9CeP2NV7BGAwUoz+G4U8urWGv+uU9a2+fPu8pszkx9rwg74bUaGnVV507Wy3q6lzo8 4YA/DqdfrXST9XWeLyPRnj/EjjQNLEYIPMFvwkq6Q7PRzFKvW0fVlV714G7z/Uhw3nSq vS27xk28VKwkmAkXcWBdwE56ba+/rc9I4Sm8W1eberp/OG0CRadiZfuZazpZIJlf7dm8 0rE+Z6R4kXT/qJTexcgq30TpfcHV9RJ2pGIu194WCwmKLtHq2D2Oz30l/U17bkz1OdvE OqpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:sender:dkim-signature; bh=IPmAvIsDewbgoAF8s7naRSTRLzReKRtE3k+XB4aF880=; fh=47q7h8JmSJyQJqkeEmWx05lDRm5gsplH0aOicx8IAws=; b=hDYdGVM6jnd6s0Qg8Um24nLO6bX+RN2Dop9NCK5fYQNUG/NbybaEMwYe2YwdZwQr90 mMSm02jHoefPABT9oZc+ip/Q6EnWdNjo9L7fwN1eIsD/2UohhFKrPIpA9YRwnpYCCC2i ebE2I648P5WbMaO7MyhUCIBIyOMssW0Z+im2OgHauBxfEL+dujnXszqX9KZp7FOroe9+ 0b/j+GZnmp6UWyrZoBwSD+VVqjmyccS0Y3LDfgoHcfnrYoNy+6qiLh+gbpqIlPvXdcUi c0A0zTh0qpquImD8dFu6HzSmsy+fmx4yDmth48b5Hhn/jKv4QMD6FnTxZtjtWESSu0l3 1wvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bVcwh3MF; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67715-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67715-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a123-20020a636681000000b005d412d0f51esi1712156pgc.661.2024.02.15.13.52.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 13:52:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67715-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bVcwh3MF; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67715-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67715-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DF54E281C1A for ; Thu, 15 Feb 2024 21:52:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7D3B1420CA; Thu, 15 Feb 2024 21:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bVcwh3MF" Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2D536A349; Thu, 15 Feb 2024 21:51:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708033912; cv=none; b=Yke2Qh8RpuI7zuUQrJPPv1b8CUJM5yApVLjfbvSuSxWhNWdGL0Que7e0wokDsu137IDn+jsAjhywOx/uHDhbSEo1mS5UzT3yHRkR5UdoxEwatm1uzIPVy19g39VWJuqAZnV1Ke7Jd7DrQShglY7b8vlglOkz6taYkrKc9Piqf/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708033912; c=relaxed/simple; bh=O42nuhICBihJWnszpZZ0NOG3Cl71f3VoQR7IUUPNH9U=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=bjl2X0dYF2a6VrnigOWMhTDRtT3HVjmH1LMyxvMtWXYiiC1EoARKwAR4OE+KrbP05Gery+qN7anxmpVDtjutghMz9Luz0HbugfTBAafdhomDYPHclcPnBnrELVYfpGuUR+RUEN+aUGy2NBSGc/PVhhdcIjv455HHefmGLKng8IQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bVcwh3MF; arc=none smtp.client-ip=209.85.166.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-36426ae1c5eso4365335ab.3; Thu, 15 Feb 2024 13:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708033908; x=1708638708; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=IPmAvIsDewbgoAF8s7naRSTRLzReKRtE3k+XB4aF880=; b=bVcwh3MFe8+fviF2XNZIbtKbNA2tT1mhU+S2LSr4AYoqFj2n2/WTtdqpcFzxm8Jlbb Il0rtgpVFC/+FlNpZYxMOXZMXRiEhBLN5VaxUNzcFU+PpuD1RwyNnWlPXtuF2jHzujxM ULyV57OCsO83ras1/R8P621TXuoaCetwoKIsvTDkky8HP0aTlRLWY30MytPOyuQufIOW 362AQYIXNBa4gDOkTvE3Qc0KMe+aMKt+QGocBRqjXWWQO3RYKhBTdnERB8tBdJxWQQI8 gOIzYGx8SR+J9abJez4xm4LhiRy2ZaC8Kp8fSXwB/tcHKcsVj8f2SA3BaItpPidoaabe xmOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708033908; x=1708638708; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IPmAvIsDewbgoAF8s7naRSTRLzReKRtE3k+XB4aF880=; b=XmTwXYneooL5MOwAWL51zbTgDOV7PHSU+ECQOw+s0xEZ8QdsGktWoKqVkvqph3CzeM vHT4GEvgG2RU7TRUrGdPC5yOwrwid6TNhR+py/3nXIX3OddWX0Nr54PliZ59KNfdM3s7 3pEygfiSnzTT5CuRAdG6NtOsF3JKCeQl5qZ3ZvCwS6bieJHHfOS8dIV13RhVUmR7ZxqD AqNxqc1il54EtFaxZAZj0QGzrVctsJzpEnbYq2nvLaZ3Y0Yf83rU4kPciH9u+lKxtqb9 dMc4CStkpJbS7WNGALHgO3s0z/FSW518qdrZLsWuOClciPVXd5/pltUiGE9esilTYfXB KbTQ== X-Forwarded-Encrypted: i=1; AJvYcCWWafvSQ5HQi3ui13epYxZhfGq/aXbCof+ohCpHysPRUx9bLltgZGBanqTRPgcXOjzKfT9DvqV/ZVA+vuvvKThHLCXsCoFaI4zS8r08Ea4xFLt8o8TloPEWdpWb6q+3ugodPRAsHqhToMcj X-Gm-Message-State: AOJu0Yx9BHo2yHmFtiCPNX7NZ4wFuN9gsoMjIbYjhM5eHhQsKvMDhnas enphrN7P1Xsxy7JOsi+6ZgXKRBJDkiBpiJJRtusgyb+u1xBwdGRqx48A7qFW X-Received: by 2002:a92:c6c7:0:b0:363:be58:cdb0 with SMTP id v7-20020a92c6c7000000b00363be58cdb0mr3227415ilm.6.1708033907744; Thu, 15 Feb 2024 13:51:47 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h63-20020a638342000000b005d8b2f04eb7sm1843319pge.62.2024.02.15.13.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 13:51:46 -0800 (PST) Sender: Guenter Roeck From: Guenter Roeck To: Helge Deller Cc: "James E . J . Bottomley" , linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Sven Schnelle , John David Anglin , Charlie Jenkins , David Laight Subject: [PATCH] parisc: Fix unwinder Date: Thu, 15 Feb 2024 13:51:45 -0800 Message-Id: <20240215215145.2103639-1-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791003383060728601 X-GMAIL-MSGID: 1791003383060728601 Debugging shows a large number of unaligned access traps in the unwinder code. Code analysis reveals a number of issues with this code: - handle_interruption is passed twice through dereference_kernel_function_descriptor() - ret_from_kernel_thread, syscall_exit, intr_return, _switch_to_ret, and _call_on_stack are passed through dereference_kernel_function_descriptor() even though they are not declared as function pointers. To fix the problems, drop one of the calls to dereference_kernel_function_descriptor() for handle_interruption, and compare the other pointers directly. Fixes: 6414b30b39f9 ("parisc: unwind: Avoid missing prototype warning for handle_interruption()") Fixes: 8e0ba125c2bf ("parisc/unwind: fix unwinder when CONFIG_64BIT is enabled") Cc: Helge Deller Cc: Sven Schnelle Cc: John David Anglin Cc: Charlie Jenkins Cc: David Laight Signed-off-by: Guenter Roeck --- Tested using qemu with B160L (32 bit) and C3700 (64 bit) machines. arch/parisc/kernel/unwind.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c index 27ae40a443b8..f7e0fee5ee55 100644 --- a/arch/parisc/kernel/unwind.c +++ b/arch/parisc/kernel/unwind.c @@ -228,10 +228,8 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, int #ifdef CONFIG_IRQSTACKS extern void * const _call_on_stack; #endif /* CONFIG_IRQSTACKS */ - void *ptr; - ptr = dereference_kernel_function_descriptor(&handle_interruption); - if (pc_is_kernel_fn(pc, ptr)) { + if (pc_is_kernel_fn(pc, handle_interruption)) { struct pt_regs *regs = (struct pt_regs *)(info->sp - frame_size - PT_SZ_ALGN); dbg("Unwinding through handle_interruption()\n"); info->prev_sp = regs->gr[30]; @@ -239,13 +237,13 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, int return 1; } - if (pc_is_kernel_fn(pc, ret_from_kernel_thread) || - pc_is_kernel_fn(pc, syscall_exit)) { + if (pc == (unsigned long)&ret_from_kernel_thread || + pc == (unsigned long)&syscall_exit) { info->prev_sp = info->prev_ip = 0; return 1; } - if (pc_is_kernel_fn(pc, intr_return)) { + if (pc == (unsigned long)&intr_return) { struct pt_regs *regs; dbg("Found intr_return()\n"); @@ -257,14 +255,14 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, int } if (pc_is_kernel_fn(pc, _switch_to) || - pc_is_kernel_fn(pc, _switch_to_ret)) { + pc == (unsigned long)&_switch_to_ret) { info->prev_sp = info->sp - CALLEE_SAVE_FRAME_SIZE; info->prev_ip = *(unsigned long *)(info->prev_sp - RP_OFFSET); return 1; } #ifdef CONFIG_IRQSTACKS - if (pc_is_kernel_fn(pc, _call_on_stack)) { + if (pc == (unsigned long)&_call_on_stack) { info->prev_sp = *(unsigned long *)(info->sp - FRAME_SIZE - REG_SZ); info->prev_ip = *(unsigned long *)(info->sp - FRAME_SIZE - RP_OFFSET); return 1;