Let's consider in dimension $d\geq 3$ the Newton/riesz potential $f=I_2[g]$ $$ f(x)=\int_{R^d}\frac{1}{|x-y|^{d-2}}g(y)dy, $$ which solves $-\Delta f=g$ (up to positive normalizing constants, which I shall ignore), and assume that $g\in L^q$ for all $q\in[1,2d/(d+2)]$. By the Hardy-Littlewood-Sobolev inequality (or any other variation from [Stein, singular inegrals], [Lieb-Loss, Analysis] etc...) we know that $f\in L^{2d/(d-2)}$, and also $\nabla f\in L^2$ (this is one way to prove the Sobolev embedding $H^1\subset L^{2d/(d-2)}$). If $p=2d/(d+2)$ the conjugated Holder exponent is exactly $p'=\frac{2d}{d-2}$, thus $g\in L^p$, $f\in L^{p'}$ and $fg\in L^1$. Since by definition $-\Delta f=g$ we would expect that $$ \int \underbrace{f}_{\in L^{p'}}\underbrace{g}_{\in L^p}=\int f(-\Delta f)\overset{?}{=}\int |\underbrace{\nabla f}_{\in L^2}|^2. $$
When is the last integration by parts legitimate? With my hypotheses all the above terms are well defined, but is this enough? I seem to remember that there are "exotic" counterexamples...
It seems to me that an approximation argument works fine: if $g_n$ is a sequence of smooth compactly supported functions such that $g_n\to g$ in $L^{2d/(d+2)}$ then by continuity (HLS inequality) we have that $f_n\to f$ in $L^{2d/(d-2)}$ and $\nabla f_n\to \nabla f$ in $L^2$. Since the integration by parts is legitimate for smooth decaying functions then it should pass to the limit... I don't think anything is wrong here, did I miss something or is it really just that easy?
Edit: I just added the approximation argument