Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2336615pxk; Mon, 14 Sep 2020 10:32:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb0LimDppMtqnuaqc1r4xKqjapSz/nkFjsAW9uLN1nhwL8q0geGFGGsAy4PYG76vsSId00 X-Received: by 2002:a17:906:a2d2:: with SMTP id by18mr15615208ejb.37.1600104774112; Mon, 14 Sep 2020 10:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600104774; cv=none; d=google.com; s=arc-20160816; b=dxoKiYP88I6pRQQk+rCTksZB1WYx68OqRfjklQw890VCdYVB0ZcKcT49CEndbpg60B ElQfWS3C93Goq6pH4Eu7/CdzxJ5V0QyTKsKiVnl2IEt4B1W7mzDijOC1rZ7HaVVy8x6X BlKrTx+MDCDZ6gRs1zL0NAybh6dqhN8BoMSTQRlReGQPMdXcrYxgx+yjnjyHFXVdfttF i/047Xn3ks6WVNsECM2QGChASN0dSY6lTnXTVrJn8AvsPdJ/qb9uZegnD+1hiZfyoBek /gQyuUJBCmwBM8xfTgWVNuyq2PE5lRg2P70u7lwdjEKJxgFqhLNOzKfiNRzZjEgMF8dA LQaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/EjNih3r7ygkjYASNBWp7YtEX1KLL1OovUvtOR4yQ8E=; b=tr7xA8aXBSSE+vHnmaumRGZ10vZOmT3IOFafdMsI4cRxQl7fazLD8OrdzqxlpBlOid yVVGhJXih9EansQdl6wGH2MuvBMQhBhl/Cn0L4K9LysMSsD+PTrFdeGhm4ZTxXKXyV7R dbPVHOJh/FLT0IsZKCUxeNsQj1BAAkcvxDs52DtSsNtfmJvIR6aXH9N7bLtGK/vfHjjQ 5AEL0tJAQaIitXPoLEMrMm/ezXrTecNZHr5+t096X3HXV/6XbFBSAtiw3v6Wis1phZ/Q 0FjQmiEQqJ5J+yVHaX1PmF0aPVxy+8WdJWrg/yPwNolmmsvUwNsXqB+/MdkqalUEpSBk Jszg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="LDOJW73/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si7748651eji.301.2020.09.14.10.32.31; Mon, 14 Sep 2020 10:32:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="LDOJW73/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726045AbgINR3o (ORCPT + 99 others); Mon, 14 Sep 2020 13:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbgINR2c (ORCPT ); Mon, 14 Sep 2020 13:28:32 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4F6BC06121E for ; Mon, 14 Sep 2020 10:28:18 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id s13so799926wmh.4 for ; Mon, 14 Sep 2020 10:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/EjNih3r7ygkjYASNBWp7YtEX1KLL1OovUvtOR4yQ8E=; b=LDOJW73/Nx4NRSF62nukRv0fkeOiLGfPXVP1aJhDKCMUKmk3HmHAf6NWlyYj1Fc30H 4ctb86ijJJ+PMUx7pA1+2eEIf+G0cmjOvbtE9oBe55C3Cvn1qkgI3USj0yAzKEsPU9q0 Kg6zWbX13Nvf35fM5FUm0vCKYp5AV89AlTGoxiq/9SNtkV9H5JeJZSjohjU7p9UCPTCc AFzF0SLwziqh80xl5uTlhqNQPcFqdMho3+ObPMEgdgw7XZugj3HlUg9gMeuZ9Wl5vn3G sEIZ2338YOSdEnkx35Dj1zujfiD6uqhHIIRpeBrFBUJeHIahNLU31ZLtfIcNVZWFj6tG ir0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/EjNih3r7ygkjYASNBWp7YtEX1KLL1OovUvtOR4yQ8E=; b=ssyEu3icJ+EHCDglqRYEsKgZCgTm65xCa2XMPSNOYcDNkbmIOq+CJb16nn/VNolx4y ACdAGUMJEghELCBK8OLVXCIOZgRZ65O/Q65m52wIZMAr2Cyfil6e42CK3x8F1b24MgnH UC5k6nmI4RLg3mT+PZ+pow65qER1/aof8CvqGDYbsCRjyNgecEsbkkUbcXfMjUchFpDq SPaqEYxMHtxw17QzRaw5Kc1qoOWGk5UMIuhW6ru2TU/MTnoP7Lb+DEblyv6obZ09OnGV BdfbDFmTVWL33GdRwlnxLDWRBFD/XYRk8JSkPJXd7TpKN2lOZWyA3Y67V+h5djOaTnnr VmlQ== X-Gm-Message-State: AOAM5303nkB/OEJqB0PvYTNb/qgmARG1QZoKJEpzYJxQFhokihObR7rp ATk1Lukdt/W+XLGA8zl5NpjkxA== X-Received: by 2002:a1c:a551:: with SMTP id o78mr486952wme.4.1600104497464; Mon, 14 Sep 2020 10:28:17 -0700 (PDT) Received: from localhost (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id a17sm22898300wra.24.2020.09.14.10.28.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 10:28:16 -0700 (PDT) From: George-Aurelian Popescu To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org, masahiroy@kernel.org, michal.lkml@markovi.net Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, natechancellor@gmail.com, ndesaulniers@google.com, dbrazdil@google.com, broonie@kernel.org, maskray@google.com, ascull@google.com, keescook@chromium.org, akpm@linux-foundation.org, dvyukov@google.com, elver@google.com, tglx@linutronix.de, arnd@arndb.de, George Popescu Subject: [PATCH 08/14] KVM: arm64: Enable UBsan check for unreachable code inside hyp/nVHE code Date: Mon, 14 Sep 2020 17:27:44 +0000 Message-Id: <20200914172750.852684-9-georgepope@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog In-Reply-To: <20200914172750.852684-1-georgepope@google.com> References: <20200914172750.852684-1-georgepope@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: George Popescu The data from __ubsan_handle_builtin_unreachable is passed to the buffer and printed inside the kernel by its symmetric handler. Signed-off-by: George Popescu --- arch/arm64/include/asm/kvm_ubsan.h | 5 ++++- arch/arm64/kvm/hyp/nvhe/ubsan.c | 12 +++++++++++- arch/arm64/kvm/kvm_ubsan_buffer.c | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_ubsan.h b/arch/arm64/include/asm/kvm_ubsan.h index 575881e0bd5f..7fd0d0dfbd82 100644 --- a/arch/arm64/include/asm/kvm_ubsan.h +++ b/arch/arm64/include/asm/kvm_ubsan.h @@ -20,10 +20,12 @@ struct ubsan_values { struct kvm_ubsan_info { enum { UBSAN_NONE, - UBSAN_OUT_OF_BOUNDS + UBSAN_OUT_OF_BOUNDS, + UBSAN_UNREACHABLE_DATA } type; union { struct out_of_bounds_data out_of_bounds_data; + struct unreachable_data unreachable_data; }; union { struct ubsan_values u_val; @@ -32,3 +34,4 @@ struct kvm_ubsan_info { #endif void __ubsan_handle_out_of_bounds(void *_data, void *index); +void __ubsan_handle_builtin_unreachable(void *_data); diff --git a/arch/arm64/kvm/hyp/nvhe/ubsan.c b/arch/arm64/kvm/hyp/nvhe/ubsan.c index b2d3404f6215..9497e7f7f397 100644 --- a/arch/arm64/kvm/hyp/nvhe/ubsan.c +++ b/arch/arm64/kvm/hyp/nvhe/ubsan.c @@ -58,6 +58,16 @@ void __ubsan_handle_out_of_bounds(void *_data, void *index) void __ubsan_handle_shift_out_of_bounds(void *_data, void *lhs, void *rhs) {} -void __ubsan_handle_builtin_unreachable(void *_data) {} +void __ubsan_handle_builtin_unreachable(void *_data) +{ + struct kvm_ubsan_info *slot; + struct unreachable_data *data = _data; + + slot = kvm_ubsan_buffer_next_slot(); + if (slot) { + slot->type = UBSAN_UNREACHABLE_DATA; + slot->unreachable_data = *data; + } +} void __ubsan_handle_load_invalid_value(void *_data, void *val) {} diff --git a/arch/arm64/kvm/kvm_ubsan_buffer.c b/arch/arm64/kvm/kvm_ubsan_buffer.c index ce796bdd027e..f66cc5f7878e 100644 --- a/arch/arm64/kvm/kvm_ubsan_buffer.c +++ b/arch/arm64/kvm/kvm_ubsan_buffer.c @@ -25,6 +25,9 @@ void __kvm_check_ubsan_data(struct kvm_ubsan_info *slot) __ubsan_handle_out_of_bounds(&slot->out_of_bounds_data, slot->u_val.lval); break; + case UBSAN_UNREACHABLE_DATA: + __ubsan_handle_builtin_unreachable(&slot->unreachable_data); + break; } } -- 2.28.0.618.gf4bc123cb7-goog