Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2146463iof; Tue, 7 Jun 2022 21:18:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOuKF/kPMlkrl/ZVTtaznujdxeRJsZ7Nh+fIux+N6s+3GRP1PX2yedYhDy58pwSPfsDYuM X-Received: by 2002:a17:902:edd1:b0:158:8318:b51e with SMTP id q17-20020a170902edd100b001588318b51emr32180924plk.89.1654661889517; Tue, 07 Jun 2022 21:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661889; cv=none; d=google.com; s=arc-20160816; b=jNrmwjZCThCkfZiB2w2hPhKSO32DyZLEEaMMJ1sEmrNNG5m5l0tCNIE+rYH8KCLJm5 0hHZrvHdPu8tKY6UGA+esdn/yTh8ULBOxujWsNtbhzlIGq1NUE0QhrbT07NOTJc5wd3w xZXzEdE/Q1jwkj1tdMFGvaZEYO0Zs64obKu8u0K+Wf88ZLjurYDo4nhm9gwdMqBrW8W1 Y2D9ZyRjhIA582pLXzlgMiC2B3yshZ1dwc4WaYpUL02XUzuW4gI7jaiEnI7U/gvskvVK NJfzI5aXBfPIXk3NXR9Kw4vW3z+dB7J80mJ/zZuNzm6Xf/+LEuRGCLMVldMWiN7Z/4W0 gl7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=utThYmevKONU/9m2pQGdDHA12doEH9idunElwn0Wp+Y=; b=T4ECzY6F28OA2nNCv7eSStjMQ7RcT+Adm1CbcNWaSs3CyUueJZnkMDQLqa9Fa3tDS3 EKDvkGSgNqw1gHK0T58rwgPrognFCBTvoXwZzyi3SSVkJjHU7JBEuyJ6vJKPkw8OHfmK wxSBxpAlCEu938ceaFChymykVuwSzSB5l14W1CrCsxXych71z0+W/vxg56KwTsGRIUFp dnvkpMlh10RTAf89R/pRLBBGvSyqFCXkeU9RSDtyXZXWaQYRIBUM2W2KwXhUYHnKEfv2 SuvlIfYGMWFQKCBAYH3AgulQ2o/zuoMcVy73N6H7Zaw9LI7Mj7CNnWLPyYePKPtOT+Bn TaDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gUIQMQl0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z15-20020a1709027e8f00b0015bfd115dcesi16413939pla.455.2022.06.07.21.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:18:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gUIQMQl0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E29892149E8; Tue, 7 Jun 2022 20:49:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343979AbiFGQvn (ORCPT + 99 others); Tue, 7 Jun 2022 12:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345197AbiFGQvm (ORCPT ); Tue, 7 Jun 2022 12:51:42 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFA52F6889 for ; Tue, 7 Jun 2022 09:51:39 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id s22-20020a252d56000000b0065d1ef35f9dso15596806ybe.5 for ; Tue, 07 Jun 2022 09:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=utThYmevKONU/9m2pQGdDHA12doEH9idunElwn0Wp+Y=; b=gUIQMQl0JQzhYd3S4fyRf5XmWfJe5lmGtNGJawPlt9xGCh6iVfChXa73AoojCUrlbl IVXeOtMoTYUHDpAFH3A8brBwPVcti7T1TXiYbRGm9WL+wI2w1S/KEwaSu9WutVR9tygx 84Kvg+VfGwL6M1f0ziUNEjgMhLSuSnn44AbVKJ9wncUs/50JTgmnIHf+wQmtrOV7M8Mt K4uO5mPCKZewDVjZ3Ihsg/rY8/0Ud5jqcoTKOFhCTALO+vhAlMfVTPQqBzexRVTQ5AE6 AWpm7eIByU/UruiBwIFFfpmgXXAyJwhbholwIR4cxXKH/anXN/52PMZ9cQYrHOq/XYDw pDWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=utThYmevKONU/9m2pQGdDHA12doEH9idunElwn0Wp+Y=; b=CpGyKSEn7XLH3/1dWBHr3H5NIq2OwmQSHJMomUoavH4sTtTs5p0bDEwgtDlsE1ICsR AV5uOWMP4mDAF8K1eJH6g/+Im3mABV+ZxJZ6HZHG8/tPPlSFeqyq17o16ADm5Xm5BUN+ E1T1qOs8L60CZDEQo8j1Uk5iIuCrSleW6EoIdia/Slu3PFfok9Sg9Ijxd/zfcIYKX9Z0 x0c6dZFomWU6qH27fZAQNU4Mo9uKcP6laVRaNVCdulCLbYzrvl/z0rC8X6JMGMYCahz7 xGRTjb6GZTbo7RJ+LoUKI5fWA0PWg5le2zvQs1hevCA61F2mTLXFG+LtxAqCsM120p/D ZjwA== X-Gm-Message-State: AOAM533xIr7zbEPbi9rCDmwUtdCzFC9TQXKPVzF0QLo0ppoOyxWj5x6n beWUsVZoYRdV6Rv2QwYV+8h9Ag1HeiUvApXSOw== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:7091:8518:ec1e:93dc]) (user=kaleshsingh job=sendgmr) by 2002:a81:57d6:0:b0:30c:a234:140d with SMTP id l205-20020a8157d6000000b0030ca234140dmr33093505ywb.269.1654620698862; Tue, 07 Jun 2022 09:51:38 -0700 (PDT) Date: Tue, 7 Jun 2022 09:50:43 -0700 In-Reply-To: <20220607165105.639716-1-kaleshsingh@google.com> Message-Id: <20220607165105.639716-2-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220607165105.639716-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog Subject: [PATCH v3 1/5] KVM: arm64: Factor out common stack unwinding logic From: Kalesh Singh To: mark.rutland@arm.com, broonie@kernel.org, maz@kernel.org Cc: will@kernel.org, qperret@google.com, tabba@google.com, surenb@google.com, tjmercier@google.com, kernel-team@android.com, Kalesh Singh , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Masami Hiramatsu , Alexei Starovoitov , "Madhavan T. Venkataraman" , Peter Zijlstra , Andrew Jones , Marco Elver , Kefeng Wang , Zenghui Yu , Keir Fraser , Ard Biesheuvel , Oliver Upton , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Factor out the stack unwinding logic common to both the host kernel and the nVHE hypersivor into __unwind_next(). This allows for reuse in the nVHE hypervisor stack unwinding (later in this series). Signed-off-by: Kalesh Singh Reviewed-by: Mark Brown --- Changes in v3: - Add Mark's Reviewed-by tag arch/arm64/kernel/stacktrace.c | 36 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 0467cb79f080..ee60c279511c 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -81,23 +81,19 @@ NOKPROBE_SYMBOL(unwind_init); * records (e.g. a cycle), determined based on the location and fp value of A * and the location (but not the fp value) of B. */ -static int notrace unwind_next(struct task_struct *tsk, - struct unwind_state *state) +static int notrace __unwind_next(struct task_struct *tsk, + struct unwind_state *state, + struct stack_info *info) { unsigned long fp = state->fp; - struct stack_info info; - - /* Final frame; nothing to unwind */ - if (fp == (unsigned long)task_pt_regs(tsk)->stackframe) - return -ENOENT; if (fp & 0x7) return -EINVAL; - if (!on_accessible_stack(tsk, fp, 16, &info)) + if (!on_accessible_stack(tsk, fp, 16, info)) return -EINVAL; - if (test_bit(info.type, state->stacks_done)) + if (test_bit(info->type, state->stacks_done)) return -EINVAL; /* @@ -113,7 +109,7 @@ static int notrace unwind_next(struct task_struct *tsk, * stack to another, it's never valid to unwind back to that first * stack. */ - if (info.type == state->prev_type) { + if (info->type == state->prev_type) { if (fp <= state->prev_fp) return -EINVAL; } else { @@ -127,7 +123,25 @@ static int notrace unwind_next(struct task_struct *tsk, state->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp)); state->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 8)); state->prev_fp = fp; - state->prev_type = info.type; + state->prev_type = info->type; + + return 0; +} +NOKPROBE_SYMBOL(__unwind_next); + +static int notrace unwind_next(struct task_struct *tsk, + struct unwind_state *state) +{ + struct stack_info info; + int err; + + /* Final frame; nothing to unwind */ + if (state->fp == (unsigned long)task_pt_regs(tsk)->stackframe) + return -ENOENT; + + err = __unwind_next(tsk, state, &info); + if (err) + return err; state->pc = ptrauth_strip_insn_pac(state->pc); -- 2.36.1.255.ge46751e96f-goog