gpu: nvgpu: use READ_ONCE/WRITE_ONCE

In the upstream kernel ACCESS_ONCE is now deprecated with reason as
given in the following related commit:

    commit 381f20fceba8e ("security: use READ_ONCE instead of deprecated
    ACCESS_ONCE")

    ACCESS_ONCE() does not work reliably on non-scalar types. For
    example gcc 4.6 and 4.7 might remove the volatile tag for such
    accesses during the SRA (scalar replacement of aggregates) step.

Replace usages of ACCESS_ONCE with READ_ONCE and WRITE_ONCE in nvgpu.

Bug 2834141

Change-Id: I9904c49e1a4d7b17ed2fe54360051d08595a2982
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2294096
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sagar Kamble
2020-02-12 22:03:12 +05:30
committed by Alex Waterman
parent 029da0437e
commit d0d8ef79d1
11 changed files with 32 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -44,7 +44,8 @@
#define nvgpu_smp_rmb() nvgpu_smp_rmb_impl()
#define nvgpu_smp_wmb() nvgpu_smp_wmb_impl()
#define NV_ACCESS_ONCE(x) NV_ACCESS((x))
#define NV_READ_ONCE(x) NV_READ_ONCE_IMPL((x))
#define NV_WRITE_ONCE(x, y) NV_WRITE_ONCE_IMPL((x), (y))
/*
* Sometimes we want to prevent speculation.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -27,7 +27,8 @@
#define nvgpu_smp_rmb_impl() smp_rmb()
#define nvgpu_smp_wmb_impl() smp_wmb()
#define NV_ACCESS(x) ACCESS_ONCE(x)
#define NV_READ_ONCE_IMPL(x) READ_ONCE(x)
#define NV_WRITE_ONCE_IMPL(x, y) WRITE_ONCE(x, y)
#define nvgpu_speculation_barrier_impl() speculation_barrier()

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -23,7 +23,9 @@
#ifndef NVGPU_POSIX_BARRIER_H
#define NVGPU_POSIX_BARRIER_H
#define ACCESS_ONCE(x) (*(volatile __typeof__(x) *)&x)
#include <nvgpu/posix/utils.h>
#define READ_ONCE(x) (*(volatile __typeof__(x) *)&x)
/*
* TODO: implement all these!
@@ -36,6 +38,7 @@
#define nvgpu_smp_rmb_impl()
#define nvgpu_smp_wmb_impl()
#define NV_ACCESS(x) ACCESS_ONCE(x)
#define NV_READ_ONCE_IMPL(x) READ_ONCE(x)
#define NV_WRITE_ONCE_IMPL(x, y) WRITE_ONCE(x, y)
#endif /* NVGPU_POSIX_BARRIER_H */