|
|
Message-ID: <a0b6690d-039e-04ed-9847-b4521935375f@huawei.com>
Date: Mon, 31 Jul 2017 21:17:40 +0800
From: Li Kun <hw.likun@...wei.com>
To: Ard Biesheuvel <ard.biesheuvel@...aro.org>
CC: <linux-arm-kernel@...ts.infradead.org>,
<kernel-hardening@...ts.openwall.com>, <will.deacon@....com>,
<keescook@...omium.org>, <mark.rutland@....com>,
<labbott@...oraproject.org>
Subject: Re: [PATCH v3] arm64: kernel: implement fast refcount checking
在 2017/7/31 20:01, Ard Biesheuvel 写道:
> +static __always_inline __must_check bool refcount_add_not_zero(unsigned int i,
> + refcount_t *r)
> +{
> + unsigned long tmp;
> + int result;
> +
> + asm volatile("// refcount_add_not_zero \n"
> +" prfm pstl1strm, %2\n"
> +"1: ldxr %w[val], %2\n"
> +" cbz %w[val], 2f\n"
> +" adds %w[val], %w[val], %w[i]\n"
> +" stxr %w1, %w[val], %2\n"
> +" cbnz %w1, 1b\n"
> + REFCOUNT_POST_CHECK_NEG
> +"2:"
> + : [val] "=&r" (result), "=&r" (tmp), "+Q" (r->refs.counter)
> + : REFCOUNT_INPUTS(&r->refs) [i] "Ir" (i)
> + : REFCOUNT_CLOBBERS);
> +
> + return result != 0;
> +}
> +
Could we use "cas" here instead of ll/sc ?
--
Best Regards
Li Kun
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.