From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FFBDC433E0 for ; Thu, 18 Mar 2021 22:40:22 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 380BC64EED for ; Thu, 18 Mar 2021 22:40:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 380BC64EED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R6CVdo+Vur8otuuFrQBJJe+zNpJUi1UFSCP1HgcSNw4=; b=ZV9RInRu5WojlvRFO28j/6pxu CAuaADNYm6PaRKHYKY2Fjy8gWskqubsToROW8A7CWmkt5yubFXZHt2I+xA4h2GRQepFZCNqDD4jkG PAQZ0sV0jmasOnwtJ4HkShB9vnXT0muj81i8f8euQsh/9CFvnOYll+txO6RD1XNU6CF2DmozeKv77 Tv5Xi341Dmwv7a2NyqTm49A2Ljj1UQzt9NVtEstrs/Sc2MKxZ19I2TLfPXOPGnXFy5e32OBsd7JZs DMbebs4C5QECzilHb0/GHRI9/6UsUb7zr+HTsYjbItdwepnXJCdaXNUg4AaZA4nrWvRSfsy7lt0Nm Mg8ijM6xw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lN1Hp-0067iA-NH; Thu, 18 Mar 2021 22:38:38 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lN1Hl-0067hf-5v for linux-arm-kernel@lists.infradead.org; Thu, 18 Mar 2021 22:38:35 +0000 Received: by mail-pf1-x42a.google.com with SMTP id j25so4500391pfe.2 for ; Thu, 18 Mar 2021 15:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=hPV6PFlpjtaaQAGr+gXeOd26mXT5CK+0etiUFA1UmqY=; b=OqRfeKnan531gNoR4Nd5w07qAxyWwLt4N1mVSIGgcrjc0OUl/C+1Ot9r8Rz6AAurhL 8yKR4OQp1/YgQCqMa9oXsNccxmz7A31fWb4dyR2/8NeJoOYpKYbNXRXtW5+/ESDng0GL 3DB9zlWP5/JOFf2FAvMxzaGAHEyWtqz4vxR6k0qXFQVA51OwkFa6b67ATPZ4wWt1rlia AojEZR7Em6bSbXuCSfvOL2wnZHF4MzRjdqj/CODxCIu/0dHpFEA48tIPbH8QJq1NAVdR CGnFotTADS8fpQMYNYv9b5ONo64lRcNFTbt3ZC2jonERPYisi7RALzmmwVpiPdguQD1s Q5FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hPV6PFlpjtaaQAGr+gXeOd26mXT5CK+0etiUFA1UmqY=; b=dRu79MOy/P9otrQZhtGSz9yPWxCGKeXwPMqbDBnM+0COfBVp/0wo+xnhB9yGvY04W3 qtu3KTQH3vHoT8umo0t5gpSFs2SM21Oniv2dvDMfXt48QNRbjIadZUe8JdeIf83WVY4D 7fU0ZDds6511gX51l9tt9b4Nxc54v9pS4xUOsvgQcQd95PX/CWU40kGChyAx8JI+jgNe 6zbC7A60BYKUJ45n8iPe6Vf/Fz/2yOLYry37FyItsv0U6o31VZ9aqVViRr/DcIxCoPfl QCMIHRziYKQY++4bvn8ih9Y/q+MXzX805DvW/5OHScHzbkyU+lvPk5YbENYYtq7UurfN 5HIQ== X-Gm-Message-State: AOAM533XtTgmly9AZ5yaTUcbkvdZQ+DZaPI3DhXq4fTCWAgnEEEIk0IZ Fp/hRjr0CQGQlsDYJH1DXHU= X-Google-Smtp-Source: ABdhPJwmZiMlog75NmzcgOTt8rBz68L8AA9VFQ3YUiU/r50zikM5233QpapMYME/h3cjmwNVdDaZOA== X-Received: by 2002:a62:800c:0:b029:203:6990:78e2 with SMTP id j12-20020a62800c0000b0290203699078e2mr6178087pfd.3.1616107109985; Thu, 18 Mar 2021 15:38:29 -0700 (PDT) Received: from f8ffc2228008.ant.amazon.com ([54.240.193.1]) by smtp.gmail.com with ESMTPSA id 10sm3300782pfp.4.2021.03.18.15.38.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Mar 2021 15:38:27 -0700 (PDT) Subject: Re: Live patching on ARM64 To: Mark Rutland , "Madhavan T. Venkataraman" Cc: linux-arm-kernel@lists.infradead.org, Mark Brown , Julien Thierry , jpoimboe@redhat.com, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210115123347.GB39776@C02TD0UTHF1T.local> From: "Singh, Balbir" Message-ID: <176e6c60-18dd-167b-41aa-dfd11e5810d3@gmail.com> Date: Fri, 19 Mar 2021 09:38:20 +1100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210115123347.GB39776@C02TD0UTHF1T.local> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210318_223833_360463_28A2A75B X-CRM114-Status: GOOD ( 45.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 15/1/21 11:33 pm, Mark Rutland wrote: > On Thu, Jan 14, 2021 at 04:07:55PM -0600, Madhavan T. Venkataraman wrote: >> Hi all, >> >> My name is Madhavan Venkataraman. > > Hi Madhavan, > >> Microsoft is very interested in Live Patching support for ARM64. >> On behalf of Microsoft, I would like to contribute. >> >> I would like to get in touch with the people who are currently working >> in this area, find out what exactly they are working on and see if they >> could use an extra pair of eyes/hands with what they are working on. >> >> It looks like the most recent work in this area has been from the >> following folks: >> >> Mark Brown and Mark Rutland: >> Kernel changes to providing reliable stack traces. >> >> Julien Thierry: >> Providing ARM64 support in objtool. >> >> Torsten Duwe: >> Ftrace with regs. > > IIRC that's about right. I'm also trying to make arm64 patch-safe (more > on that below), and there's a long tail of work there for anyone > interested. > >> I apologize if I have missed anyone else who is working on Live Patching >> for ARM64. Do let me know. I am quite interested as well, I did some of the work for ppc64le >> >> Is there any work I can help with? Any areas that need investigation, any code >> that needs to be written, any work that needs to be reviewed, any testing that >> needs to done? You folks are probably super busy and would not mind an extra >> hand. > > One general thing that I believe we'll need to do is to rework code to > be patch-safe (which implies being noinstr-safe too). For example, we'll > need to rework the instruction patching code such that this cannot end > up patching itself (or anything that has instrumented it) in an unsafe > way. Do we know how this differs across architectures? Usually kprobe and ftrace unsafe functions are annotated as such, is there more to it? > > Once we have objtool it should be possible to identify those cases > automatically. Currently I'm aware that we'll need to do something in at > least the following places: > > * The entry code -- I'm currently chipping away at this. Could you please explain, whats bits of the entry code? I suspect we never patch anything in assembly > > * The insn framework (which is used by some patching code), since the > bulk of it lives in arch/arm64/kernel/insn.c and isn't marked noinstr. > noinstr is largely kcsan and kasan related, right? > We can probably shift the bulk of the aarch64_insn_gen_*() and > aarch64_get_*() helpers into a header as __always_inline functions, > which would allow them to be used in noinstr code. As those are > typically invoked with a number of constant arguments that the > compiler can fold, this /might/ work out as an optimization if the > compiler can elide the error paths. > > * The alternatives code, since we call instrumentable and patchable > functions between updating instructions and performing all the > necessary maintenance. There are a number of cases within > __apply_alternatives(), e.g. > > - test_bit() > - cpus_have_cap() > - pr_info_once() > - lm_alias() > - alt_cb, if the callback is not marked as noinstr, or if it calls > instrumentable code (e.g. from the insn framework). > - clean_dcache_range_nopatch(), as read_sanitised_ftr_reg() and > related code can be instrumented. > > This might need some underlying rework elsewhere (e.g. in the > cpufeature code, or atomics framework). > > So on the kernel side, maybe a first step would be to try to headerize > the insn generation code as __always_inline, and see whether that looks > ok? With that out of the way it'd be a bit easier to rework patching > code depending on the insn framework. > > I'm not sure about the objtool side, so I'll leave that to Julien and co > to answer. Thanks, it would be good to see what the expectations from objtool are, I thought only x86 needed it due to variable size instructions and -fomit- frame-pointers Balbir Singh. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel