Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7563175ybl; Thu, 16 Jan 2020 01:37:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwXzdX5GR0KaJQOT9Cmcoo7cEOzKVkfW6L48czcOabYLcsBO8X2ia3qf6nDEEk1s3EQIpjn X-Received: by 2002:a05:6808:292:: with SMTP id z18mr3269915oic.131.1579167470423; Thu, 16 Jan 2020 01:37:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579167470; cv=none; d=google.com; s=arc-20160816; b=sMa7I5VwU9Z/izYjV1UPzKoq/G3Ut6MCs1NNy1U7iKrgzf2NtFWJH3vKFo9hDh5KVL QuNb7+b7PihchV7zpB10Tg7vO79QEfjnchMT/FRGo+PCRVyAe8tp/9hHfpu+LXmwWEwl f3Myh9LqQVhG+rSx0OiZ3UoN4PHxjsff1/Zj7x2q9HW1pqCvHuA/mlCYz3F3e9uOVZtx UFSjGXxyFeQXiwopVDo41+tR0R8Ga46Npv2K4SdZbfInT/mI5vYEwJzVbJCzZHBufB/X QndMo4tl3YzxbZts51C9Ovut+yVKndH5gRfaBo2YMmbRm3t0J3M167yBt2vYkTA16FnQ B7Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gJg5ZRxNcTyn3n/fup2Ib0eaCQR42k4DrKQJxK1gJxw=; b=di1QRg+h11k9OytVnMq2209y28FrJFSV+NDXuW4xOXz/4jI3jzplyXaz6zglC+s5oC fgCfLn1wT5NZ7q69cujlZoB+1kqxoqTKZGiYZduoqPy3z4GIaVIm0LBKDTNkwk0gif1h UD5hlIqh5Xwhl//e0VexOP6sLBl6IHtn1TXpPOabrLXtNFruu6Q+yiiRMnuRlN9dl0wv KRuueBKKyXuasaAQYIJJihxdcS6CUmQzSIXdAjgedudiykOm/Hr3ugMY8V7m1L0u7fe4 zhuwGnohXHGEtU2AOKy7Yui+ogNglBTbxF9q5sFX+UxBy30i6LUrKOQN9wmaVwFTlD8Q IFyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=G12enqTe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id i6si14231269otj.24.2020.01.16.01.37.38; Thu, 16 Jan 2020 01:37:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=G12enqTe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729504AbgAPIoU (ORCPT + 99 others); Thu, 16 Jan 2020 03:44:20 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:33544 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727009AbgAPIoU (ORCPT ); Thu, 16 Jan 2020 03:44:20 -0500 Received: by mail-qk1-f195.google.com with SMTP id d71so18426603qkc.0 for ; Thu, 16 Jan 2020 00:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gJg5ZRxNcTyn3n/fup2Ib0eaCQR42k4DrKQJxK1gJxw=; b=G12enqTe8piIdk84hriOXaCMmvMjuAV+b54nRadwgz9fnOZDPZjMVs6vyaOMZm6BhT RoWzO8xuYgT5kkQqno/sAIDSdLvfhCH+2P8/sapey7phZaTUWKVwMp2KtXujHD3w1rlk /bO6qrGSD9k/Xs7LsYwOZrmyqSeS95pmTZcsjr/W3hYr+ljqd7jmLyxVOZw/ICWeDoRR tYP7OmYgGPokerki2/GaxidmGPM+wINVw42Zw+k45k2T+IF0Wws2xmfXmAYdYnx3ESw5 xhWlWlBSi5iX65Zd7PIY+HDXryTM2ykiffxi/kmIc6XBhjflgYZg79y+RB2U6uYCzIPM b4mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gJg5ZRxNcTyn3n/fup2Ib0eaCQR42k4DrKQJxK1gJxw=; b=rk0MWsn5JfSQj6yKfA+yFdPvO0jFm2dem2DesKpAHFWSt2KNw4npJjV28t1OUHhL9F oqea2d+gLdVjLcuehc8b7FedS78hA914aBCwNQMVDHc1TC8Gt6mi1kH9IaVmshLXJR/7 HU0XoSF8b/M/n2CWHdUcjtIAZzZfFWpslYyPj9tAa5BwRLUoVTQj0SbDHszIhF2UlRGs xZhAkef8zQDLRX4kd9LkDE07ciPQVxzYbYrXlHmR5ZmmMIETIFopgqx2D1lTN0rPMuJG z8UJfDjlIUc4Re2Hyu55lw8zxjuRonNgiuvJUaNXhXI9g7YpxjKjtB6voq3eqySp5++2 H74g== X-Gm-Message-State: APjAAAVBZI9/YHfT+1b8f27kbH2crI+ar1ij6TD1f3+OlvzXtt9sq99m F127cE8kSiZ3jMvMwFNat1jOL+i2ok1j+ztTTvaYUw== X-Received: by 2002:a37:e312:: with SMTP id y18mr32326765qki.250.1579164259120; Thu, 16 Jan 2020 00:44:19 -0800 (PST) MIME-Version: 1.0 References: <20200115182816.33892-1-trishalfonso@google.com> In-Reply-To: <20200115182816.33892-1-trishalfonso@google.com> From: Dmitry Vyukov Date: Thu, 16 Jan 2020 09:44:08 +0100 Message-ID: Subject: Re: [RFC PATCH] UML: add support for KASAN under x86_64 To: Patricia Alfonso Cc: Jeff Dike , Richard Weinberger , anton.ivanov@cambridgegreys.com, Andrey Ryabinin , David Gow , Brendan Higgins , linux-um@lists.infradead.org, kasan-dev , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 15, 2020 at 7:28 PM Patricia Alfonso wrote: > +config KASAN_SHADOW_OFFSET > + hex > + depends on KASAN > + default 0x100000000000 > + help > + This is the offset at which the ~2.25TB of shadow memory is > + initialized and used by KASAN for memory debugging. The default > + is 0x100000000000. What are restrictions on this value? In user-space we use 0x7fff8000 as a base (just below 2GB) and it's extremely profitable wrt codegen since it fits into immediate of most instructions. We can load and add the base with a short instruction: 2d8c: 48 81 c2 00 80 ff 7f add $0x7fff8000,%rdx Or even add base, load shadow and check it with a single 7-byte instruction: 1e4: 80 b8 00 80 ff 7f 00 cmpb $0x0,0x7fff8000(%rax) While with the large base, it takes 10 bytes just to load the const into a register (current x86 KASAN codegen): ffffffff81001571: 48 b8 00 00 00 00 00 fc ff df movabs $0xdffffc0000000000,%rax Most instructions don't have 8-byte immediates, so then we separately need to add/load/check.